Skip to content

Commit

Permalink
LibWeb: Ensure a repaint occurs when the current selection is cleared
Browse files Browse the repository at this point in the history
This fixes an issue where clearing the find in page query would not
always visually clear the selection.

(cherry picked from commit 0b33331f3678eb69bc3448949dfc2c1e1e7671e6)
  • Loading branch information
tcl3 authored and nico committed Nov 1, 2024
1 parent 0d5346a commit 6bd6ab6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Userland/Libraries/LibWeb/DOM/Range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ void Range::set_associated_selection(Badge<Selection::Selection>, JS::GCPtr<Sele

void Range::update_associated_selection()
{
if (!m_associated_selection)
return;
if (auto* viewport = m_associated_selection->document()->paintable()) {
if (auto* viewport = m_start_container->document().paintable()) {
viewport->recompute_selection_states();
viewport->set_needs_display();
}

if (!m_associated_selection)
return;

// https://w3c.github.io/selection-api/#selectionchange-event
// When the selection is dissociated with its range, associated with a new range or the associated range's boundary
// point is mutated either by the user or the content script, the user agent must queue a task on the user interaction
Expand Down

0 comments on commit 6bd6ab6

Please sign in to comment.