From 7f2582fca95e307145edcaa4a0e686ae45e4b446 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Thu, 8 Feb 2024 21:01:25 +0000 Subject: [PATCH] LibWeb: Update the cursor position when an editable element is clicked With this change, clicking on an editable element, such as an `input` or `textarea` causes the cursor position to be updated to the current mouse position. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index db6c3050b0..adc8dfc1d5 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -405,12 +405,14 @@ 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); + } + // 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 || paintable->dom_node()->is_editable()) { 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()) {