You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Button: replace :has([data-kbd-chord]) with a data attribute set from React #8724
Button/ButtonBase.module.css:28 and :217 use &:has([data-kbd-chord]), which applies to every Button. A :has() selector makes the browser re-check the button whenever its descendants change. Earlier work (#8115, #7901) removed many similar :has() selectors.
Proposed fix
Set a data-* attribute on the button from React when it renders a keybinding hint, as ActionList does for its item state. Then select on that attribute instead of :has().
Acceptance criteria
ButtonBase.module.css no longer uses :has([data-kbd-chord]).
Buttons with and without a keybinding hint look the same as before. Check the VRT snapshots for the affected stories.
I've recently had two open-source PRs merged, including a frontend performance fix and a set of regression tests.
I'd like to investigate replacing the :has([data-kbd-chord]) selectors with a React-controlled data attribute, while preserving the existing button styling and behavior.
Is this issue available for an external contribution? I'd be happy to work on it.
I've started working on this and have the initial regression tests in place.
I noticed that PR #8115 intentionally retained the Button :has([data-kbd-chord]) selectors because trailingVisual can be an arbitrary render function, making it difficult to detect a KeybindingHint during rendering.
Would you prefer an explicit prop to indicate the presence of a keybinding hint, or is there another approach you'd recommend that preserves existing trailingVisual usage without introducing DOM queries?
I'd like to make sure the implementation stays backwards-compatible before moving forward.
Activity
SimonGebru commentedon Nov 15, 2026
Hi! I'd be interested in working on this issue.
I've recently had two open-source PRs merged, including a frontend performance fix and a set of regression tests.
I'd like to investigate replacing the
:has([data-kbd-chord])selectors with a React-controlled data attribute, while preserving the existing button styling and behavior.Is this issue available for an external contribution? I'd be happy to work on it.
tay1orjones commentedon Nov 16, 2026
Bumped this to a P2 because how often Button is used.
@SimonGebru Yeah, absolutely!
SimonGebru commentedon Nov 17, 2026
Hi @tay1orjones!
I've started working on this and have the initial regression tests in place.
I noticed that PR #8115 intentionally retained the Button
:has([data-kbd-chord])selectors becausetrailingVisualcan be an arbitrary render function, making it difficult to detect aKeybindingHintduring rendering.Would you prefer an explicit prop to indicate the presence of a keybinding hint, or is there another approach you'd recommend that preserves existing
trailingVisualusage without introducing DOM queries?I'd like to make sure the implementation stays backwards-compatible before moving forward.