mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00: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:
parent
dbd09454c4
commit
b07a576c22
Notes:
github-actions[bot]
2026-02-11 10:28:56 +00:00
Author: https://github.com/gmta
Commit: b07a576c22
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7859
4 changed files with 28 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue