1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:47:35 +00:00

LibWeb: Run the unfocusing steps when a click does not focus anything

For example, when clicking the document body outside of a focused input
element, we should unfocus that element.
This commit is contained in:
Timothy Flynn 2023-12-03 09:54:26 -05:00 committed by Andreas Kling
parent 48240a6fc3
commit fd297a3248
6 changed files with 42 additions and 0 deletions

View file

@ -409,6 +409,9 @@ bool EventHandler::handle_mousedown(CSSPixelPoint position, CSSPixelPoint screen
// If we didn't focus anything, place the document text cursor at the mouse position.
// FIXME: This is all rather strange. Find a better solution.
if (!did_focus_something) {
if (auto* focused_element = document->focused_element())
HTML::run_unfocusing_steps(focused_element);
auto& realm = document->realm();
m_browsing_context->set_cursor_position(DOM::Position::create(realm, *paintable->dom_node(), result->index_in_node));
if (auto selection = document->get_selection()) {