From 9a3434efb406a12a725c8d28aed50939bb3157ae Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 21 Apr 2025 11:28:49 -0300 Subject: [PATCH] component preview: Focus search input immediately upon opening (#29155) Just a quick quality of life improvement to make keyboard navigation in this view a bit better. When you open the Component Preview view now, the "filter" search input will be focused right off the bat. Release Notes: - N/A --- crates/component_preview/src/component_preview.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/component_preview/src/component_preview.rs b/crates/component_preview/src/component_preview.rs index 276271828e553cccd9020fecf313ba73277e32e9..74105a0213a9394c4ff13e5b4384a17ce7206059 100644 --- a/crates/component_preview/src/component_preview.rs +++ b/crates/component_preview/src/component_preview.rs @@ -166,6 +166,9 @@ impl ComponentPreview { component_preview.update_component_list(cx); + let focus_handle = component_preview.filter_editor.read(cx).focus_handle(cx); + window.focus(&focus_handle); + component_preview } @@ -779,10 +782,13 @@ impl Item for ComponentPreview { fn added_to_workspace( &mut self, workspace: &mut Workspace, - _window: &mut Window, - _cx: &mut Context, + window: &mut Window, + cx: &mut Context, ) { self.workspace_id = workspace.database_id(); + + let focus_handle = self.filter_editor.read(cx).focus_handle(cx); + window.focus(&focus_handle); } }