Skip to content

fix(Button): improve a11y with loading state #8778

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

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

Conversation

galimovkirill
Copy link

@galimovkirill galimovkirill commented Jul 21, 2025


  • Unit-тесты
  • Release notes

Описание

Задаем корректные атрибуты для кнопки в состоянии loading для улучшения a11y.
Более явное различие между нативной кнопкой и ссылкой для скринридеров.

Release notes

  • Button: улучшено a11y для кнопок с href, а также в состоянии loading

@galimovkirill galimovkirill requested a review from a team as a code owner July 21, 2025 22:55
Copy link
Contributor

e2e tests

Playwright Report

Copy link
Contributor

👀 Docs deployed

📦 Package ✅

yarn add @vkontakte/vkui@https://vkui-screenshot.hb.bizmrg.com/pull/8778/5b41d1246f5dcd2447b6ec1cba6675f5b2a8a369/pkg/@vkontakte/vkui/_pkg.tgz

Commit 5b41d12

Copy link

codecov bot commented Jul 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.96%. Comparing base (4a18ba6) to head (5b41d12).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8778   +/-   ##
=======================================
  Coverage   95.96%   95.96%           
=======================================
  Files         419      419           
  Lines       12141    12150    +9     
  Branches     4033     4037    +4     
=======================================
+ Hits        11651    11660    +9     
  Misses        490      490           
Flag Coverage Δ
unittests 95.96% <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.

🚀 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.

return (
<Tappable
hoverMode={styles.hover}
activeMode={styles.active}
Component={restProps.href ? 'a' : 'button'}
Component={href ? 'a' : 'button'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

disabled режим для тега a не так прост как кажтся на первый взгляд. Чтобы все работало правильно, необходимо учесть следующее:

  • Тег a не поддерживает атрибут disabled, поэтому используем aria-disabled
  • Тег a с атрибутом href все еще кликабельный, поэтому ему нужно перестать передавать href
  • Тег a без href не является ссылкой, поэтому добавляем role="link".

https://w3c.github.io/html-aria/#example-communicate-a-disabled-link-with-aria

Компонент Tappable под капотом уже умеет обрабатывать href и disabled, поэтому все что нам нужно, это при href не пробрасывать свойство Component

Suggested change
Component={href ? 'a' : 'button'}
{...(href === undefined && { Component: 'button' })}
image

@inomdzhon
Copy link
Contributor

Привет,

Спасибо за PR

Это изменение решили делать в v8.0.0, т.к. может быть брейкинг чендж (добавил соотвествующий лейбл в задаче, забыли добавить). Планируем начать разработку v8.0.0 в сентябре, поэтому PR повесит до сентября.

Пока можно править замечания по ревью

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

Successfully merging this pull request may close these issues.

[Bug][Button]: Разобраться с доступностью loading кнопок
3 participants