From 547c9c182713ccf2dbc29476f24e945f5070af3d Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Fri, 25 Apr 2025 19:06:39 +0800 Subject: [PATCH] gallery: Fix the error active panel display with search keywords (#817) ## Before https://github.com/user-attachments/assets/25b925e5-c0f3-42b0-97f3-190fb738a10a ## After https://github.com/user-attachments/assets/2d6e2b23-f3e2-45fd-a58c-69f31d0646a8 --- crates/story/src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/story/src/main.rs b/crates/story/src/main.rs index f7f54d60..8eb8fce7 100644 --- a/crates/story/src/main.rs +++ b/crates/story/src/main.rs @@ -1,7 +1,7 @@ use gpui::{prelude::*, *}; use gpui_component::{ h_flex, - input::TextInput, + input::{InputEvent, TextInput}, sidebar::{Sidebar, SidebarGroup, SidebarHeader, SidebarMenu, SidebarMenuItem}, v_flex, ActiveTheme as _, Icon, IconName, }; @@ -24,10 +24,13 @@ impl Gallery { .cleanable() .placeholder("Search...") }); - let _subscriptions = vec![cx.subscribe(&search_input, |this, _, _, cx| { - this.active_group_index = None; - this.active_index = None; - cx.notify() + let _subscriptions = vec![cx.subscribe(&search_input, |this, _, e, cx| match e { + InputEvent::Change(_) => { + this.active_group_index = Some(0); + this.active_index = Some(0); + cx.notify() + } + _ => {} })]; let stories = vec![ (