fix(react): allow Toggle to disable focus via data-is-focusable attri...#35846
Open
Br1an67 wants to merge 1 commit intomicrosoft:masterfrom
Open
fix(react): allow Toggle to disable focus via data-is-focusable attri...#35846Br1an67 wants to merge 1 commit intomicrosoft:masterfrom
Br1an67 wants to merge 1 commit intomicrosoft:masterfrom
Conversation
…bute The Toggle component now respects the data-is-focusable attribute, allowing users to disable focus behavior similar to the Checkbox component. This is particularly useful in DetailsList scenarios where arrow key navigation should skip certain interactive elements. Previously, data-is-focusable was hardcoded to true, preventing users from disabling focus. Now it checks toggleNativeProps for the attribute and defaults to true if not provided, maintaining backward compatibility.
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.
Fixes #31935
Previous Behavior
The Toggle component had a hardcoded
data-is-focusable="true"attribute, which prevented users from disabling focus behavior. This was problematic in scenarios like DetailsList where arrow key navigation should skip certain interactive elements, similar to how Checkbox allows this viainputProps={{ "data-is-focusable": false }}.New Behavior
The Toggle component now respects the
data-is-focusableattribute passed as a prop. Users can now disable focus by passingdata-is-focusable={false}to the Toggle component, making it consistent with the Checkbox component's behavior. The default value remainstrueto maintain backward compatibility.Usage Example
Related Issue(s)
Changes
Toggle.base.tsxto checktoggleNativeProps['data-is-focusable']and default totrueif not provided