Skip to content

Commit

Permalink
LibWeb: Update element style when focus state changes
Browse files Browse the repository at this point in the history
To ensure that :focus rules get included (or excluded), we have to
update style whenever focus moves.
  • Loading branch information
awesomekling committed Mar 3, 2022
1 parent ef33a40 commit 88aa356
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Userland/Libraries/LibWeb/DOM/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,17 @@ void Document::set_focused_element(Element* element)
if (m_focused_element == element)
return;

if (m_focused_element)
if (m_focused_element) {
m_focused_element->did_lose_focus();
m_focused_element->set_needs_style_update(true);
}

m_focused_element = element;

if (m_focused_element)
if (m_focused_element) {
m_focused_element->did_receive_focus();
m_focused_element->set_needs_style_update(true);
}

if (m_layout_root)
m_layout_root->set_needs_display();
Expand Down

0 comments on commit 88aa356

Please sign in to comment.