mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Always focus on editing host if currently not focused
We were constraining the focusing behavior for editing hosts a bit too much; regardless of how the selection changed, if the start container is inside an editing host and it's currently not focused, we should focus it. This fixes focus stealing by other elements that set a selection inside an editing host on a click event, for example.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
3a741b0ce6
commit
738eb68dda
Notes:
github-actions[bot]
2025-08-20 10:05:42 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/738eb68dda6 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5921
@@ -549,9 +549,8 @@ void Selection::set_range(GC::Ptr<DOM::Range> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user