Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[A11Y]: Modification de la propriété isHidden pour rendre le label accessible" #1270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions src/elements/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import styled from 'styled-components'
import type { LabelHTMLAttributes } from 'react'

export type LabelProps = LabelHTMLAttributes<HTMLLabelElement> & {
$isHidden?: boolean | undefined
$isRequired?: boolean | undefined
disabled?: boolean | undefined
hasError?: boolean | undefined
isHidden?: boolean | undefined
}
export const Label = styled.label.attrs<LabelProps, LabelProps>(props => ({
className: classnames('Element-Label', props.className)
}))`
color: ${p =>
// eslint-disable-next-line no-nested-ternary
p.disabled ? p.theme.color.lightGray : p.hasError ? p.theme.color.maximumRed : p.theme.color.slateGray};
display: ${p => (p.isHidden ? 'none' : 'block')};
font-size: 13px;
line-height: 1.3846;
margin-bottom: 4px;
Expand All @@ -25,14 +26,4 @@ export const Label = styled.label.attrs<LabelProps, LabelProps>(props => ({
content:" *";
color: ${p.theme.color.maximumRed};
}`}
${p =>
p.$isHidden &&
`
position:absolute;
left:-10000px;
top:auto;
width:1px;
height:1px;
overflow:hidden;
`}
`
2 changes: 1 addition & 1 deletion src/fields/CheckPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function CheckPicker<OptionValue extends OptionValueType = string>({

return (
<Field className={controlledClassName} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/MultiCascader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function MultiCascader<OptionValue extends OptionValueType = string>({

return (
<Field className={controlledClassName} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function MultiSelect<OptionValue extends OptionValueType = string>({

return (
<Field className={controlledClassName} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function NumberInput({

return (
<Field className={controlledClassname} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/PhoneInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const PhoneInput = forwardRef<HTMLInputElement, PhoneInputProps>(

return (
<Field className="Field-PhoneInput">
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={name} isHidden={isLabelHidden}>
{label}
</Label>
<StyledIMaskInput
Expand Down
2 changes: 1 addition & 1 deletion src/fields/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function Search<OptionValue extends OptionValueType = string>({

return (
<Field className={controlledClassName} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function Select<OptionValue extends OptionValueType = string>({

return (
<Field className={controlledClassname} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function TextInput({

return (
<Field className={controlledClassname} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function Textarea({

return (
<Field className={controlledClassname} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>

Expand Down
2 changes: 1 addition & 1 deletion src/fields/Toggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function Toggle({

return (
<Field className={controlledClassName} style={style}>
<Label $isHidden={isLabelHidden} $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name}>
<Label $isRequired={isRequired} disabled={disabled} htmlFor={originalProps.name} isHidden={isLabelHidden}>
{label}
</Label>
<StyledToggle
Expand Down
4 changes: 2 additions & 2 deletions stories/elements/Label.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type { LabelProps } from '../../src'
import type { Meta } from '@storybook/react'

const args: LabelProps = {
$isHidden: false,
$isRequired: false,
children: 'A form input label',
disabled: false
disabled: false,
isHidden: false
}

/* eslint-disable sort-keys-fix/sort-keys-fix */
Expand Down
Loading