Skip to content

The open source coding agent.

TypeScript

feat(ui): add onFilter callback to List, discard add server row when searching

David Hill8845f2b92687
diff --git a/packages/app/src/components/dialog-select-server.tsx b/packages/app/src/components/dialog-select-server.tsx
index 99fd221628f..8f4b99a4ff7 100644
--- a/packages/app/src/components/dialog-select-server.tsx
+++ b/packages/app/src/components/dialog-select-server.tsx
@@ -367,6 +367,11 @@ export function DialogSelectServer() {
onSelect={(x) => {
if (x) select(x)
}}
+ onFilter={(value) => {
+ if (value && store.addServer.showForm && !store.addServer.adding) {
+ resetAdd()
+ }
+ }}
divider={true}
class="px-5 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]:max-h-[300px] [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-raised-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent [&_[data-slot=list-item-add]]:px-0"
add={
diff --git a/packages/ui/src/components/list.tsx b/packages/ui/src/components/list.tsx
index 5f585f90cad..2132897f7cf 100644
--- a/packages/ui/src/components/list.tsx
+++ b/packages/ui/src/components/list.tsx
@@ -38,6 +38,7 @@ export interface ListProps<T> extends FilteredListProps<T> {
loadingMessage?: string
onKeyEvent?: (event: KeyboardEvent, item: T | undefined) => void
onMove?: (item: T | undefined) => void
+ onFilter?: (value: string) => void
activeIcon?: IconProps["name"]
filter?: string
search?: ListSearchProps | boolean
@@ -98,6 +99,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
const current = internalFilter()
if (prev !== current) {
onInput(current)
+ props.onFilter?.(current)
}
return current
}, "")