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

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.
This commit is contained in:
Tim Ledbetter 2024-02-08 21:01:25 +00:00 committed by Andreas Kling
parent d4932196cc
commit 7f2582fca9

View file

@ -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()) {