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

fix(TabbarItem): avoid double focus #8241

Conversation

andrey-medvedev-vk
Copy link
Contributor

@andrey-medvedev-vk andrey-medvedev-vk commented Feb 5, 2025


  • Unit-тесты
  • Release notes

Описание

Двойной фокус при переходе через TabbarItem's табом происходит в основном из-за того, что внутри TabbarItem, который является кнопкой/ссылкой, лежит интерактивный Tappable. Tappable внутри нужен для того, чтобы на android был ripple эффект.


Видел решение #5914. Тоже изначально думал как бы оставить один Tappable, но решил сделать быстрый фикс конкретно этого поведения. Но в целом, в будущем стоит отрефакторить TabbarItem, чтобы избавиться от ненужных нод и упростить компонент.

Изменения

  • убраем возможность фокуса на Tappable через tabindex="-1".
  • добавляем focus-visible у Tappable при фокусировании на TabbarItem. Так как иначе при фокусе с клавиатуры вообще фокуса видно не будет, из-за tabindex="-1".

Release notes

Исправления

  • TabItem: исправляем необходимость дважды нажимать таб на одном элементе

Disable focus from inner Tappable element that is made for
ripple effect
@github-actions github-actions bot added the patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча label Feb 5, 2025
Copy link

codesandbox-ci bot commented Feb 5, 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 Feb 5, 2025

size-limit report 📦

Path Size
JS 395.11 KB (+0.04% 🔺)
JS (gzip) 119.82 KB (+0.05% 🔺)
JS (brotli) 98.53 KB (+0.06% 🔺)
JS import Div (tree shaking) 1.56 KB (0%)
CSS 347.71 KB (0%)
CSS (gzip) 43.03 KB (0%)
CSS (brotli) 34.37 KB (0%)

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.53%. Comparing base (4f2d7c0) to head (a33fd80).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8241   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files         404      404           
  Lines       11553    11559    +6     
  Branches     3836     3837    +1     
=======================================
+ Hits        11037    11043    +6     
  Misses        516      516           
Flag Coverage Δ
unittests 95.53% <100.00%> (+<0.01%) ⬆️

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.

Copy link
Contributor

github-actions bot commented Feb 5, 2025

e2e tests

Playwright Report

@andrey-medvedev-vk andrey-medvedev-vk marked this pull request as ready for review February 5, 2025 11:27
@andrey-medvedev-vk andrey-medvedev-vk requested a review from a team as a code owner February 5, 2025 11:27
Copy link
Contributor

github-actions bot commented Feb 5, 2025

👀 Docs deployed

Commit a33fd80

@andrey-medvedev-vk andrey-medvedev-vk merged commit 2b144f4 into master Feb 7, 2025
29 checks passed
@andrey-medvedev-vk andrey-medvedev-vk deleted the mendrew/2743/fix/TabbarItem/fix-keyboard-focus-state branch February 7, 2025 08:21
vkcom-publisher pushed a commit that referenced this pull request Feb 7, 2025
Двойной фокус при переходе через `TabbarItem`'s табом происходит в основном из-за того, что внутри `TabbarItem`, который является кнопкой/ссылкой, лежит интерактивный `Tappable`. `Tappable` внутри нужен для того, чтобы на android был ripple эффект.

------

Видел решение #5914. Тоже изначально думал как бы оставить один Tappable, но решил сделать быстрый фикс конкретно этого поведения. Но в целом, в будущем стоит отрефакторить TabbarItem, чтобы избавиться от ненужных нод и упростить компонент.

Изменения
- убраем возможность фокуса на `Tappable` через tabindex="-1".
- добавляем focus-visible у `Tappable` при фокусировании на `TabbarItem`. Так как иначе при фокусе с клавиатуры вообще фокуса видно не будет, из-за tabindex="-1".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Автоматизация: PR продублируется в ветку последнего минорного релиза для выпуска патча
Projects
None yet
3 participants