@@ -29,6 +29,7 @@ import {
2929 PopoverTrigger ,
3030} from '@teable/ui-lib/shadcn' ;
3131import Link from 'next/link' ;
32+ import { useParams } from 'next/navigation' ;
3233import { useRouter } from 'next/router' ;
3334import { useTranslation } from 'next-i18next' ;
3435import { useMemo , useState } from 'react' ;
@@ -89,14 +90,7 @@ export const SpaceSwitcher = () => {
8990
9091 const pinMap = usePinMap ( ) ;
9192 const { spaceList } = useSpaceList ( ) ;
92- const currentSpaceId = router . query . spaceId as string | undefined ;
93-
94- const handleOpenChange = ( isOpen : boolean ) => {
95- setOpen ( isOpen ) ;
96- if ( isOpen ) {
97- setHighlightedValue ( currentSpaceId ) ;
98- }
99- } ;
93+ const { spaceId : currentSpaceId } = useParams < { spaceId : string } > ( ) ;
10094
10195 const { data : subscriptionList } = useQuery ( {
10296 queryKey : [ 'subscription-summary-list' ] ,
@@ -134,6 +128,13 @@ export const SpaceSwitcher = () => {
134128 } ,
135129 } ) ;
136130
131+ const handleOpenChange = ( isOpen : boolean ) => {
132+ setOpen ( isOpen ) ;
133+ if ( isOpen ) {
134+ setHighlightedValue ( currentSpaceId ) ;
135+ }
136+ } ;
137+
137138 const handleCreateSpace = ( ) => {
138139 const name =
139140 spaceName . trim ( ) ||
@@ -170,7 +171,17 @@ export const SpaceSwitcher = () => {
170171 </ PopoverTrigger >
171172
172173 < PopoverContent className = "min-w-[360px] p-0" align = "start" >
173- < Command value = { highlightedValue } onValueChange = { setHighlightedValue } >
174+ < Command
175+ value = { highlightedValue }
176+ onValueChange = { setHighlightedValue }
177+ filter = { ( value , search , keywords ) => {
178+ const searchLower = search . toLowerCase ( ) ;
179+ if ( keywords ?. some ( ( keyword ) => keyword . toLowerCase ( ) . includes ( searchLower ) ) ) {
180+ return 1 ;
181+ }
182+ return 0 ;
183+ } }
184+ >
174185 < div className = "px-4 pb-2 pt-4" >
175186 < p className = "pb-2 text-sm font-semibold " >
176187 { t ( 'space:allSpaces' ) } ({ spaceList ?. length || 0 } )
@@ -195,6 +206,7 @@ export const SpaceSwitcher = () => {
195206 < CommandItem
196207 key = { space . id }
197208 value = { space . id }
209+ keywords = { [ space . name ] }
198210 onSelect = { ( ) => handleSelectSpace ( space ) }
199211 className = { cn ( 'group flex items-center gap-2 rounded-md h-10' ) }
200212 >
0 commit comments