From e3baec48073c6907eef33e53de288edf5985748c Mon Sep 17 00:00:00 2001 From: Michael Mc Donnell Date: Thu, 3 Jul 2025 10:04:02 -0400 Subject: [PATCH] servoshell: Select address bar text on click (#37839) In Firefox, clicking on the address bar selects all the text. This makes Servo to do the same. I reworked the code so that the shortcut only changes the focus. That means that either clicking or the shortcut changes the focus which in turn selects the text. Testing: I tested it manually by clicking in the address bar and using the shortcuts and noticing that the text was selected. Signed-off-by: Michael Mc Donnell --- ports/servoshell/desktop/minibrowser.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/servoshell/desktop/minibrowser.rs b/ports/servoshell/desktop/minibrowser.rs index 46957fdde05..b88c5c3b705 100644 --- a/ports/servoshell/desktop/minibrowser.rs +++ b/ports/servoshell/desktop/minibrowser.rs @@ -340,7 +340,11 @@ impl Minibrowser { i.clone().consume_key(Modifiers::ALT, Key::D) } }) { + // The focus request immediately makes gained_focus return true. location_field.request_focus(); + } + // Select address bar text when it's focused (click or shortcut). + if location_field.gained_focus() { if let Some(mut state) = TextEditState::load(ui.ctx(), location_id) { @@ -352,6 +356,7 @@ impl Minibrowser { state.store(ui.ctx(), location_id); } } + // Navigate to address when enter is pressed in the address bar. if location_field.lost_focus() && ui.input(|i| i.clone().key_pressed(Key::Enter)) {