fix(focus): handle single radio button in FocusScope#9587
Open
jtstothard wants to merge 4 commits intoadobe:mainfrom
Open
fix(focus): handle single radio button in FocusScope#9587jtstothard wants to merge 4 commits intoadobe:mainfrom
jtstothard wants to merge 4 commits intoadobe:mainfrom
Conversation
eea74d2 to
0722c48
Compare
Fixes adobe#9569 form.elements.namedItem() returns an Element (not RadioNodeList) when there is exactly one element with that name. This caused TypeError when trying to spread a non-iterable Element. The fix checks if namedItem() returns a single Element before spreading, handling all three possible return types per the DOM spec: - RadioNodeList (iterable) for 2+ elements with the same name - Element (NOT iterable) for exactly 1 element - null for no elements
0722c48 to
d4ca5a5
Compare
snowystinger
reviewed
Feb 3, 2026
Member
snowystinger
left a comment
There was a problem hiding this comment.
Thanks, one change I'm making so that we don't regress on our IFrame support
snowystinger
reviewed
Feb 3, 2026
Member
snowystinger
left a comment
There was a problem hiding this comment.
apologies, it didn't like that i spanned a non-touched line for some reason
snowystinger
approved these changes
Feb 3, 2026
Author
|
@snowystinger thanks for the review, is there any way to add the ready to review tag so others review too? |
Member
|
thanks for the reminder, it's actually just a tag for myself, has no bearing on when others will review it |
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.
Summary
Fixes #9569
FocusScopecrashes withTypeError: (intermediate value) is not iterablewhen containing a form with exactly one unchecked radio button.Root Cause
Per the DOM spec,
form.elements.namedItem()returns:RadioNodeList(iterable) for 2+ elements with the same nameElement(NOT iterable) for exactly 1 elementnullfor no elementsThe
isTabbableRadiofunction assumed it always returnsRadioNodeListand tried to spread it, causing the crash.Solution
Refactored into two pure functions with proper type narrowing:
Key improvements:
getRadiosInGroupas a pure function with early returnsletdeclarations - onlyconstinstanceofchecks and type predicatesisTabbableRadiois now a simple compositionTesting
Checklist