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

feat(DateInput): make accessible for screen readers #8419

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

andrey-medvedev-vk
Copy link
Contributor


  • Unit-тесты
  • e2e-тесты
  • Дизайн-ревью
  • Документация фичи
  • Release notes

Описание

В данный момент DateInput является недоступным для скринридеров. Полный список проблем в #4932

Изменения

  • используем роль spintbutton (и соответствующие этой роли aria-аттрибуты) для InputLike компонентов, чтобы они не только были похожи на инпут, но и являлись для скринридеров чем-то вроде счётчиков, только тогда пользователям ассестивных технологий понятно как менять в них значение (с клавиатуры стрелочками)
  • фокус внутри DateInput переделан. Раньше нельзя было вернуться на предыдущий компонент, стоящий перед DateInput, из-за того, что фокус был зациклен внутри инпута.
    Теперь можно свободно перемещаться с помощью фокуса.
  • (спрятано за пропом, но надо будет жестко включить в v8) календарь не открывается при фокуса на инпут.
    Календарь можно открыть только по клику на символ календаря. (Это повторяет логику нативного input type="date" и DateInput из MaterialUI.
  • (под пропом) Поэтому иконка календаря теперь всегда видна и не прячется, если в инпуте выбрана дата.
  • календарь имеет FocusTrap и не даёт выйти за свои пределы пока не закрыт. Иначе пользователи скринридеров не могут понять как где календарь найти и где его границы. Поведение подобно modal.
  • данные календаря лежат в таблице с помощью role="grid". Это позволяет пользователям скринридеров проще ориентироваться по календарю и прыгать ровно внутрь его содержимого сочетанием клавиш к которому они привыкли. ( в NVDA есть возможость прыгнуть внутрь контента ближайшей таблицы, очень удобно, если в модалке календаря есть ещё и заголовок с переключением дня/месяца/года, по которому не хочется лишний раз проходить)
  • исправлен фокус с клавиатуры у дней. По TAB мы должны иметь возможность попасть в контент календаря, на текущий выбранный день, либо последний день на котором был фокус прежде чем пользователь ушел из таблицы календаря. Если пользователь сменил месяц через селект, то при нажатии на Tab выбраться должен первый день месяца.
  • ...

Release notes

Copy link

codesandbox-ci bot commented Mar 31, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

github-actions bot commented Mar 31, 2025

size-limit report 📦

Path Size
JS 405.72 KB (+0.6% 🔺)
JS (gzip) 120.63 KB (+0.62% 🔺)
JS (brotli) 99.23 KB (+0.72% 🔺)
JS import Div (tree shaking) 1.56 KB (0%)
CSS 348.95 KB (0%)
CSS (gzip) 43.22 KB (-0.01% 🔽)
CSS (brotli) 34.49 KB (-0.02% 🔽)

Copy link
Contributor

github-actions bot commented Mar 31, 2025

e2e tests

⚠️ Some screenshots were failed. See Playwright Report.

Playwright Report

Copy link
Contributor

github-actions bot commented Mar 31, 2025

👀 Docs deployed

Commit 224b033

This role is not recommended to use by MDN
Better to use native inputs, but it might be perfect fit
for our case when the majority of input functionality is
  done by InputLike component.

Need to test in NVDA
In Calendar days navigation
Preserve focus state on focused day.
It means when user uses Tab to move away from
focused day on calendar we keep it's value,
so, when user goes back to it we focus exactly that
day.
Allow to navigate to days using Tab
and focusable day is current value in the input,
or first day of the Month if month is changed,
but input value is not.
That is allowed by validator
Add day label without specific year, as it is too match info on calendar
to listen
When the calendar is opened we don't have
selected value in the input
Should we have one?
For some reason when we focus first or last
element of DateInput from the outside using Tab,
then we focus the first InputLike, but the content of
it is not selected for some reason.
The delay allows us to visually show the selection
It falls outside of iframe if we
disable iframe.
Add Panel and View and use iframe to
keep render it properly inside the doc
Dialog is enough here.
We allow to interact with other element
before closing the Calendar
Since if follow MUI calendar we should
show viewDate as label there

We keep changeDayLabel in DateInput since
it needs to be in the input
@andrey-medvedev-vk andrey-medvedev-vk force-pushed the mendrew/fix/DateInput/a11y branch from 08b6122 to 224b033 Compare April 11, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment