Skip to content

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

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

Closed
wants to merge 7 commits into 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

Sorry, something went wrong.

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 410.57 KB (+0.69% 🔺)
JS (gzip) 121.73 KB (+0.68% 🔺)
JS (brotli) 99.63 KB (+0.6% 🔺)
JS import Div (tree shaking) 1.56 KB (0%)
CSS 348.97 KB (0%)
CSS (gzip) 43.23 KB (-0.01% 🔽)
CSS (brotli) 34.52 KB (+0.03% 🔺)

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

📦 Package ✅

yarn add @vkontakte/vkui@https://vkui-screenshot.hb.bizmrg.com/pull/8419/57d959bea1e6c3052c8aec98aa382885bbce7c9b/pkg/@vkontakte/vkui/_pkg.tgz

Commit 57d959b

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.80%. Comparing base (deb34b2) to head (57d959b).
Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8419      +/-   ##
==========================================
+ Coverage   95.57%   95.80%   +0.23%     
==========================================
  Files         413      413              
  Lines       11766    11856      +90     
  Branches     3899     3930      +31     
==========================================
+ Hits        11245    11359     +114     
+ Misses        521      497      -24     
Flag Coverage Δ
unittests 95.80% <100.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andrey-medvedev-vk andrey-medvedev-vk force-pushed the mendrew/fix/DateInput/a11y branch from ef8438c to 2e3b239 Compare April 15, 2025 15:42
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.

Fix focus with TAB/Shift + TAB
Open calendar by <Space> and always show calendar icon
Add FocusTrap to DateInput
Add role dialog to DateInput calendar
Add support for Home/End/PageUp/PageDown
  In Calendar days navigation
Add grid role to Calendar

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.

Fix navigation with keyaboard through days

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.

Allow NVDA to navigate via ctrl+alt+arrow

Restore focus on active day

Select date on Enter/Space key

No label with date if there is no value

Add day label without specific year, as it is too match info on calendar
to listen

Fix click outside logic

When the calendar is opened we don't have
selected value in the input
Should we have one?

Visually focus days when user clicks on label

Delay range selection to fix Firefox behavior

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

Fix position of Calendar in doc Readme

It falls outside of iframe if we
disable iframe.
Add Panel and View and use iframe to
keep render it properly inside the doc

Add current month label to the table grid

Remove aria-modal="true"

Dialog is enough here.
We allow to interact with other element
before closing the Calendar

Deprecate changeDayLabel in 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

Add label for Calendar in DateInput

Fix attribute name

Add accessible prop

Add a11y section into DateInput doc

Add calendar toggle on calendar icon click

Open calendar on Click on text

Don't show calendar icon if calendar show is off

Open calendar when user click on input

CalendarRange: Small fix for keyboard Enter/Space click behavior

Allow to control restoreFocus of FocusTrap

Move Calendar back inside FormField

Add note that calendar is now can be opened by click on input
@andrey-medvedev-vk andrey-medvedev-vk force-pushed the mendrew/fix/DateInput/a11y branch from 47412b1 to a77ea65 Compare April 17, 2025 15:51
Include in tab focus test hour/minutes inputs
secuense of <T> (jump into the closest table) and
then <Ctrl>+<Alt>+ArrowKeys
Since Label goes out of grid structure
@andrey-medvedev-vk
Copy link
Contributor Author

Разбили на более мелкие PRы: #8487 и #8488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment