handle natively focusable, disabled, and hidden elements in focustrap#11245
Merged
handle natively focusable, disabled, and hidden elements in focustrap#11245
Conversation
…ed, and visibility
srietkerk
reviewed
Apr 3, 2026
| let currentNode: Node | null = walker.nextNode(); | ||
| while (currentNode) { | ||
| elements.push(currentNode as Element); | ||
| currentNode = walker.nextNode(); |
Contributor
There was a problem hiding this comment.
Are there any scenarios where the nextNode() will always return something and we get stuck in this loop?
Member
Author
There was a problem hiding this comment.
i don't think it's possible, unless you have some really twisted recursive xml or something like that
srietkerk
approved these changes
Apr 3, 2026
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 microsoft/pxt-microbit#6744
this PR modifies our isFocusable logic to handle natively focusable elements (like anchor tags with hrefs), elements with the disabled attributes, and hidden elements.
also adds two helper functions: getFocusableDescendants and getTabbableDescendants which get the elements that are focusable or tabbable respectively. in general, i tried to write the code so that it calls isVisible as infrequently as possible since that is an expensive check.
also includes a fix for the focus indicator outline on social buttons which i noticed while testing the use case in the linked issue.
@microbit-robert @microbit-matt-hillsdon FYI