mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Select contents of <input> when tabbing through fields
Browsers seem to make it convenient to replace an <input>'s contents by selecting all text on focusing, but only if you used keyboard navigation. Programmatic focus and clicking on the field do not show this behavior.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
dbd09454c4
commit
b07a576c22
Notes:
github-actions[bot]
2026-02-11 10:28:56 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/b07a576c229 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7859
@@ -1472,8 +1472,12 @@ void HTMLInputElement::did_receive_focus()
|
||||
if (m_placeholder_text_node)
|
||||
m_placeholder_text_node->invalidate_style(DOM::StyleInvalidationReason::DidReceiveFocus);
|
||||
|
||||
if (has_selectable_text())
|
||||
document().get_selection()->remove_all_ranges();
|
||||
if (has_selectable_text()) {
|
||||
if (document().last_focus_trigger() == FocusTrigger::Key)
|
||||
MUST(select());
|
||||
else
|
||||
document().get_selection()->remove_all_ranges();
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLInputElement::did_lose_focus()
|
||||
|
||||
Reference in New Issue
Block a user