feat(react-switch): add disabledFocusable prop#35799
Draft
Conversation
Co-authored-by: mainframev <14054752+mainframev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add disabledFocusable to Switch component
feat(react-switch): add Feb 27, 2026
disabledFocusable prop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch lacked a
disabledFocusableprop, forcing consumers to manually simulate visually-disabled-but-focusable behavior—leading to inconsistent, error-prone implementations. This addsdisabledFocusableto Switch, consistent with Button and other Fluent UI interactive components.Changes
Switch.types.ts— AddeddisabledFocusable?: booleantoSwitchProps; added toSwitchStaterequired picksuseSwitch.tsx— WhendisabledFocusable=true:aria-disabled="true"on the<input>instead ofdisabled(keeps element in tab order)ev.preventDefault()in the change handler to block state mutationdisabled || disabledFocusabletoLabelfor consistent visual statedisabledFocusablefrom native props forwarded to<input>useSwitchStyles.styles.ts— Added[aria-disabled="true"]CSS selectors inuseInputBaseClassNamemirroring the:disabledrules. Key specificity considerations:[aria-disabled="true"]:not(:checked)and[aria-disabled="true"]:checkedvariants match the specificity (0,4,0) of the:enabled:not(:checked)/:enabled:checkedrules and are ordered after them in the reset class to win the cascadeButtonFace/GrayText) placed after:enabled:checkedto override theHighlightactive stylesSwitch.test.tsx— Added tests for focus retention, checked-state immutability, andonChangesuppression whendisabledFocusableSwitchDisabled.stories.tsx— Added unchecked and checkeddisabledFocusableexamplesUsage
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.