Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7432aeeb7c556549276f6d1c2d764f8ab6d4790f
https://github.com/WebKit/WebKit/commit/7432aeeb7c556549276f6d1c2d764f8ab6d4790f
Author: Ahmad Saleem <[email protected]>
Date: 2026-08-21 (Fri, 21 Aug 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-summary.tentative-expected.txt
A
LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt
R
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt
R
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt
M Source/WebCore/html/HTMLButtonElement.cpp
M Source/WebCore/html/HTMLSummaryElement.cpp
Log Message:
-----------
Typing a space in editable content inside <summary> or <button> also
activates it
https://bugs.webkit.org/show_bug.cgi?id=322245
rdar://185479319
Reviewed by Ryosuke Niwa.
HTMLSummaryElement and HTMLButtonElement implement space activation across three
events: keydown calls setActive(true), keypress marks the event handled to
suppress
scrolling, and keyup dispatches a simulated click if the element is still
active.
Neither checks whether the key press was actually directed at the element. When
an
editing host is nested inside the <summary>/<button>, the editor handles the
keypress
at the target and marks it handled, so
callDefaultEventHandlersInBubblingOrder() stops
before reaching the ancestor -- but keydown and keyup are not consumed, so they
bubble
into these handlers, which set the active state and then dispatch a click. The
result
is that typing a space into the editable element both inserts the space and
toggles the
<details> / activates the <button>.
Gate the keyboard handling on the element itself being focused. Focus is the
right
discriminator rather than the event target: <summary contenteditable> is both
focused
and editable and must still toggle (the summary's own handler runs before the
editor's,
so no text is inserted), while a focused editable descendant must not activate
the
ancestor. Using the focused element also avoids depending on event target
retargeting,
which keeps the auto-generated <summary> inside <details>'s user-agent shadow
tree
working.
*
LayoutTests/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt:
Progression
*
LayoutTests/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-summary.tentative-expected.txt:
Ditto
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt:
Renamed from
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt.
*
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/editing/other/typing-space-in-editable-button.tentative-expected.txt:
Removed.
* Source/WebCore/html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler):
* Source/WebCore/html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::defaultEventHandler):
Canonical link: https://commits.webkit.org/319628@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications