mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb: Put cursor in last text node when contenteditable is focused
With this change we match behavior of other engines a bit more closer.
This commit is contained in:
parent
da42c19cb6
commit
d88e6bee5d
Notes:
github-actions[bot]
2024-10-22 12:46:09 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: d88e6bee5d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1903
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/trflynn89 ✅
3 changed files with 23 additions and 1 deletions
|
@ -757,7 +757,18 @@ void HTMLElement::did_receive_focus()
|
|||
{
|
||||
if (m_content_editable_state != ContentEditableState::True)
|
||||
return;
|
||||
document().set_cursor_position(DOM::Position::create(realm(), *this, 0));
|
||||
|
||||
DOM::Text* text = nullptr;
|
||||
for_each_in_inclusive_subtree_of_type<DOM::Text>([&](auto& node) {
|
||||
text = &node;
|
||||
return TraversalDecision::Continue;
|
||||
});
|
||||
|
||||
if (!text) {
|
||||
document().set_cursor_position(DOM::Position::create(realm(), *this, 0));
|
||||
return;
|
||||
}
|
||||
document().set_cursor_position(DOM::Position::create(realm(), *text, text->length()));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-accesskeylabel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue