Skip to content

Commit

Permalink
fix(DateInput): fix DateInput and DateRangeInput a11y (#7953)
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarMuhamethanov authored Dec 11, 2024
1 parent a1285fe commit 642925b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/vkui/src/components/DateInput/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { InputLike } from '../InputLike/InputLike';
import { InputLikeDivider } from '../InputLike/InputLikeDivider';
import { Popper } from '../Popper/Popper';
import { Text } from '../Typography/Text/Text';
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';
import '../InputLike/InputLike.module.css'; // Reorder css
import styles from './DateInput.module.css';

Expand Down Expand Up @@ -193,6 +194,7 @@ export const DateInput = ({
yearFieldTestId,
hourFieldTestId,
minuteFieldTestId,
id,
onApply,
...props
}: DateInputProps): React.ReactNode => {
Expand Down Expand Up @@ -320,8 +322,9 @@ export const DateInput = ({
onFocus={callMultiple(handleFieldEnter, onFocus)}
{...props}
>
<input
type="hidden"
<VisuallyHidden
id={id}
Component="input"
name={name}
value={value ? format(value, enableTime ? "dd.MM.yyyy'T'HH:mm" : 'dd.MM.yyyy') : ''}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/vkui/src/components/DateInput/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ const Example = () => {
]}
/>
</FormItem>
<FormItem>
<FormItem top="Результат" htmlFor="date">
<Flex>
<LocaleProvider value={locale}>
<DateInput
id="date"
value={value}
onChange={setValue}
enableTime={enableTime}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const DateRangeInput = ({
calendarTestsProps,
startDateTestsProps,
endDateTestsProps,
id,
...props
}: DateRangeInputProps): React.ReactNode => {
const daysStartRef = React.useRef<HTMLSpanElement>(null);
Expand Down Expand Up @@ -300,8 +301,9 @@ export const DateRangeInput = ({
onFocus={callMultiple(handleFieldEnter, onFocus)}
{...props}
>
<input
type="hidden"
<VisuallyHidden
id={id}
Component="input"
name={name}
value={
value
Expand Down
3 changes: 2 additions & 1 deletion packages/vkui/src/components/DateRangeInput/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ const Example = () => {
]}
/>
</FormItem>
<FormItem>
<FormItem top="Результат" htmlFor="date-range">
<Flex>
<LocaleProvider value={locale}>
<DateRangeInput
id="date-range"
value={value}
onChange={setValue}
disablePast={disablePast}
Expand Down

0 comments on commit 642925b

Please sign in to comment.