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

This commit is contained in:
David Hill
2026-01-24 21:08:04 +00:00
parent df4d839577
commit 8845f2b926
2 changed files with 7 additions and 0 deletions

View File

@@ -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={

View File

@@ -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
}, "")