From 7078769ba31fbbae43f7699a55bfaeff51407e1e Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 13 Aug 2025 13:51:04 +0200 Subject: [PATCH] LibWeb: Don't indicate focus for all form associated elements This was a misinterpretation of the spec; we should only indicate focus if the form associated element supports keyboard input, for which FormAssociatedTextControlElement is a much better match. --- Libraries/LibWeb/DOM/Element.cpp | 2 +- .../Text/expected/focus-shouldIndicateFocus.txt | 2 ++ .../Text/input/focus-shouldIndicateFocus.html | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt create mode 100644 Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 807972156aa..9c4c9a41798 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -4078,7 +4078,7 @@ bool Element::should_indicate_focus() const // * If the element which supports keyboard input (such as an input element, or any other element that would // triggers a virtual keyboard to be shown on focus if a physical keyboard were not present), indicate focus. - if (is(this)) + if (is(this)) return true; // * If the user interacts with the page via keyboard or some other non-pointing device, indicate focus. (This means diff --git a/Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt b/Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt new file mode 100644 index 00000000000..014d9b8162e --- /dev/null +++ b/Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt @@ -0,0 +1,2 @@ +INPUT: rgb(0, 0, 0) auto 3px +BUTTON: rgb(0, 0, 0) 0px diff --git a/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html b/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html new file mode 100644 index 00000000000..850d2a9e27e --- /dev/null +++ b/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html @@ -0,0 +1,17 @@ + +
+ + +