UI x-radio: fix keyboard navigation when value of first/last radio option is null#4308
Merged
calebporzio merged 3 commits intoFeb 11, 2026
Conversation
ekwoka
suggested changes
Jul 19, 2024
Comment on lines
+109
to
+110
| let index = all.indexOf(option) | ||
| let next = all.length > index + 1 ? all[index + 1] : all[0] |
Contributor
There was a problem hiding this comment.
Suggested change
| let index = all.indexOf(option) | |
| let next = all.length > index + 1 ? all[index + 1] : all[0] | |
| let index = all.indexOf(option) | |
| let next = all[(index + 1 + all.length) % all.length] |
Comment on lines
+118
to
+119
| let index = all.indexOf(option) | ||
| let prev = index >= 1 ? all[all.indexOf(option) - 1] : all.slice(-1)[0] |
Contributor
There was a problem hiding this comment.
Suggested change
| let index = all.indexOf(option) | |
| let prev = index >= 1 ? all[all.indexOf(option) - 1] : all.slice(-1)[0] | |
| let index = all.indexOf(option) | |
| let prev = all[(index - 1 + all.length) % all.length] |
Collaborator
PR Review: #4308 — UI x-radio: fix keyboard navigation when value of first/last radio option is nullType: Bug fix What's happening (plain English)
Other approaches considered
Changes MadeNo changes made — the PR is clean as-is. Test Results
Code Review
SecurityNo security concerns identified. VerdictMerge this. It's a clean, surgical two-line fix (per function) that replaces a broken falsy-fallback pattern with correct modular arithmetic. The tests are well-written and empirically verified. The PR also incidentally fixes a separate indexing bug in Reviewed by Claude |
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.
When the first or last
x-radio:optionhas null as value, then keyboard navigation does not work correctly. It skips that option because it thinks that is already reached the end or beginning of the options array (caused bynext || all[0]orprev || all.slice(-1)[0]). See screen recordings as a visual example.Untitled2.mov
Untitled.mov