Skip to content
Permalink
Browse files
Make sure :active is removed on keyup for radios.
When the radio input is checked, we need to make sure that the active flag is
set to false on keyup in order to to prevent the radio from being stuck in the
active state.

This is an import of Chromium CL at
https://chromium-review.googlesource.com/c/chromium/src/+/2466297

https://bugs.webkit.org/show_bug.cgi?id=235530

Reviewed by Chris Dumez.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-double-activate-pseudo-expected.txt:
* Source/WebCore/html/RadioInputType.cpp:
(WebCore::RadioInputType::handleKeyupEvent):

Canonical link: https://commits.webkit.org/250734@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ziransun committed May 19, 2022
1 parent 7ef0c28 commit 3bca5a58733a6dd1b8ee10f6d6d81d1b7132c61f
Showing 2 changed files with 6 additions and 2 deletions.
@@ -1,4 +1,4 @@


FAIL <input type=radio> shouldn't have the :active pseudo element after pressing the spacebar twice. assert_equals: If the radio doesn't have the :active pseudo selector, nothing else should either. expected null but got Element node <input type="radio" id="radioinput"></input>
PASS <input type=radio> shouldn't have the :active pseudo element after pressing the spacebar twice.

@@ -166,8 +166,12 @@ void RadioInputType::handleKeyupEvent(KeyboardEvent& event)
ASSERT(element());
// If an unselected radio is tabbed into (because the entire group has nothing
// checked, or because of some explicit .focus() call), then allow space to check it.
if (element()->checked())
if (element()->checked()) {
// If we are going to skip DispatchSimulatedClick, then at least call setActive(false)
// to prevent the radio from being stuck in the active state.
element()->setActive(false);
return;
}
dispatchSimulatedClickIfActive(event);
}

0 comments on commit 3bca5a5

Please sign in to comment.