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
This commit is contained in:
Floyd Wang 2025-04-25 19:06:39 +08:00 committed by GitHub
parent f946560837
commit 547c9c1827
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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![
(