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

Calendar: fix tab ordering when we use enableTime and doneButtonShow #8457

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andrey-medvedev-vk
Copy link
Contributor


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

Описание

Исправляем поведение CalendarTime и логику фокуса.
Сейчас, если мы рендерим Calendar со временем, но без кнопки "Готово", то при проходе по Calendar с помощью Tab мы застреваем на инпуте с минутами.

С одной стороны это из-за того, что мы не учли, что кнопки "Готово" может не быть в #8002

Но даже если это исправить, можно заметить, что фокус хоть и переходит из инпута минут куда-то, но он явно не попадает на следующий интерактивный элемент при одном нажатии Tab. Только со следующего нажатия Tab фокус действительно переходит дальше.

Оказалось, что причина в том, что в CustomSelect, когда дропдаун с опциями открыт, и имеет много элементов, так что появляется скролл, то при нажатии Tab мы фокусируемся на дропдауне. Но, из-за того, что дропдаун закрывается сразу после нажатия Tab, то фокус переходит на document. Так как это происходит очень быстро, то даже не понятно что такой эффект вообще есть.
Мы частично решили эту проблему в #8002 путём ручного управления фокусом, и это помогло в связке | инпут Часов | инпут Минут | кнопка Готово |, но дальнейший переход на следующий в порядке DOM интерактивный элемент всё равно сломан.

Решил установки tabIndex -1 на CustomScrollView внутри CustomSelectDropdown.


В CustomSelect добавил tabIndex -2 для нативного селекта, чтобы в тестах фокус не попадал на этот селект.

Изменения

Release notes

Native select in CustomSelect has -1 tabIndex to fix issues in test
where userEvent.tab moves focus to native select inside CustomSelect

Set tabIndex to -1 on CustomScrollView of CustomSelect
otherwise when we hit tab with opened dropdown which has
a lot of options those creates scroll inside CustomScrollView
the focus goes first to the CustomScrollView which dissapears as
dropdown is closed, after that the focus goes to the document.body
which is unexpected
@andrey-medvedev-vk andrey-medvedev-vk changed the title Calenadr: fix tab ordering when we use enableTime and doneButtonShow Calendar: fix tab ordering when we use enableTime and doneButtonShow Apr 11, 2025
Copy link

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

size-limit report 📦

Path Size
JS 402.94 KB (-0.09% 🔽)
JS (gzip) 119.78 KB (-0.11% 🔽)
JS (brotli) 98.4 KB (-0.13% 🔽)
JS import Div (tree shaking) 1.56 KB (0%)
CSS 348.97 KB (0%)
CSS (gzip) 43.23 KB (0%)
CSS (brotli) 34.51 KB (0%)

Copy link
Contributor

e2e tests

⚠️ Some screenshots were failed. See Playwright Report.

Playwright Report

Copy link
Contributor

👀 Docs deployed

Commit a5573b4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant