Bug 1892529: Skip hidden radio buttons when determining which radio button to focus. r=smaug

This fixes two problems:
1. If no radio button is checked and the first radio button is hidden, tabbing will reach the first visible radio button in the group, rather than just skipping the group.
2. If you press down arrow or up arrow and the next/previous radio button is hidden, focus will move to the next/previous visible radio button in the group, rather than doing nothing.

Differential Revision: https://phabricator.services.mozilla.com/D208092
This commit is contained in:
James Teh
2024-05-09 00:14:55 +00:00
parent 954e498e1e
commit 6367099168
3 changed files with 57 additions and 3 deletions

View File

@@ -3790,6 +3790,12 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
if (mType == FormControlType::InputRadio && keyEvent->IsTrusted() &&
!keyEvent->IsAlt() && !keyEvent->IsControl() &&
!keyEvent->IsMeta()) {
// Radio button navigation needs to check visibility, so flush
// to ensure visibility is up to date.
if (Document* doc = GetComposedDoc()) {
doc->FlushPendingNotifications(
FlushType::EnsurePresShellInitAndFrames);
}
rv = MaybeHandleRadioButtonNavigation(aVisitor, keyEvent->mKeyCode);
}