diff --git a/Libraries/LibWeb/Selection/Selection.cpp b/Libraries/LibWeb/Selection/Selection.cpp index 8777d139ab9..51b268749cd 100644 --- a/Libraries/LibWeb/Selection/Selection.cpp +++ b/Libraries/LibWeb/Selection/Selection.cpp @@ -549,9 +549,8 @@ void Selection::set_range(GC::Ptr range) // https://developer.mozilla.org/en-US/docs/Web/API/Selection#behavior_of_selection_api_in_terms_of_editing_host_focus_changes // AD-HOC: Focus editing host if the previous selection was outside of it. There seems to be no spec for this. if (range && range->start_container()->is_editable_or_editing_host()) { - GC::Ptr old_editing_host = old_range ? old_range->start_container()->editing_host() : nullptr; GC::Ref new_editing_host = *range->start_container()->editing_host(); - if (new_editing_host != old_editing_host && document()->focused_element() != new_editing_host) { + if (document()->focused_element() != new_editing_host) { // FIXME: Determine and propagate the right focus trigger. HTML::run_focusing_steps(new_editing_host, nullptr, HTML::FocusTrigger::Other); } diff --git a/Tests/LibWeb/Text/expected/selection-focuses-editing-host.txt b/Tests/LibWeb/Text/expected/selection-focuses-editing-host.txt index be2795ad27e..be67c9120c4 100644 --- a/Tests/LibWeb/Text/expected/selection-focuses-editing-host.txt +++ b/Tests/LibWeb/Text/expected/selection-focuses-editing-host.txt @@ -1,2 +1,9 @@ +-- Simple editing host -- Range: [object Text] 1 [object Text] 2 -document.activeElement: [object HTMLDivElement] +
+-- Editing host with nested -- +Range: [object Text] 1 [object Text] 1 +
+-- Refocusing on same editing host -- +Range: [object Text] 0 [object Text] 0 +
diff --git a/Tests/LibWeb/Text/input/selection-focuses-editing-host.html b/Tests/LibWeb/Text/input/selection-focuses-editing-host.html index bad433e94f7..1b71c937e5f 100644 --- a/Tests/LibWeb/Text/input/selection-focuses-editing-host.html +++ b/Tests/LibWeb/Text/input/selection-focuses-editing-host.html @@ -1,15 +1,31 @@ -
foo
+
foo
+
foobar
+