feat(ui): add onFilter callback to List, discard add server row when searching
This commit is contained in:
@@ -367,6 +367,11 @@ export function DialogSelectServer() {
|
|||||||
onSelect={(x) => {
|
onSelect={(x) => {
|
||||||
if (x) select(x)
|
if (x) select(x)
|
||||||
}}
|
}}
|
||||||
|
onFilter={(value) => {
|
||||||
|
if (value && store.addServer.showForm && !store.addServer.adding) {
|
||||||
|
resetAdd()
|
||||||
|
}
|
||||||
|
}}
|
||||||
divider={true}
|
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"
|
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={
|
add={
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export interface ListProps<T> extends FilteredListProps<T> {
|
|||||||
loadingMessage?: string
|
loadingMessage?: string
|
||||||
onKeyEvent?: (event: KeyboardEvent, item: T | undefined) => void
|
onKeyEvent?: (event: KeyboardEvent, item: T | undefined) => void
|
||||||
onMove?: (item: T | undefined) => void
|
onMove?: (item: T | undefined) => void
|
||||||
|
onFilter?: (value: string) => void
|
||||||
activeIcon?: IconProps["name"]
|
activeIcon?: IconProps["name"]
|
||||||
filter?: string
|
filter?: string
|
||||||
search?: ListSearchProps | boolean
|
search?: ListSearchProps | boolean
|
||||||
@@ -98,6 +99,7 @@ export function List<T>(props: ListProps<T> & { ref?: (ref: ListRef) => void })
|
|||||||
const current = internalFilter()
|
const current = internalFilter()
|
||||||
if (prev !== current) {
|
if (prev !== current) {
|
||||||
onInput(current)
|
onInput(current)
|
||||||
|
props.onFilter?.(current)
|
||||||
}
|
}
|
||||||
return current
|
return current
|
||||||
}, "")
|
}, "")
|
||||||
|
|||||||
Reference in New Issue
Block a user