From 3a741b0ce6b55e37b73b3c93b4449c2c6c209048 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 20 Aug 2025 10:20:07 +0200 Subject: [PATCH] LibWeb: Indicate focus on contenteditable elements This mirrors what Chrome and Firefox do. --- Libraries/LibWeb/DOM/Element.cpp | 2 +- Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt | 1 + Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index 396378bbf35..2f6bf43ed1c 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) || is_editable_or_editing_host()) 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 index 014d9b8162e..6cf291adf8d 100644 --- a/Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt +++ b/Tests/LibWeb/Text/expected/focus-shouldIndicateFocus.txt @@ -1,2 +1,3 @@ INPUT: rgb(0, 0, 0) auto 3px BUTTON: rgb(0, 0, 0) 0px +DIV: rgb(0, 0, 0) auto 3px diff --git a/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html b/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html index 850d2a9e27e..bf963337116 100644 --- a/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html +++ b/Tests/LibWeb/Text/input/focus-shouldIndicateFocus.html @@ -1,6 +1,7 @@
+
baz