File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,25 @@ const { navigationByCategory } = useNavigation(navigation!)
1010
1111const { contains } = useFilter ({ sensitivity: ' base' })
1212const filteredNavigation = computed (() => {
13- if (! value .value ) {
13+ if (! searchTerm .value ) {
1414 return navigationByCategory .value
1515 }
1616
1717 return navigationByCategory .value .map (item => ({
1818 ... item ,
19- children: item .children ?.filter (child => contains (child .title as string , value .value ) || contains (child .description as string , value .value ))
19+ children: item .children ?.filter (child => contains (child .title as string , searchTerm .value ) || contains (child .description as string , searchTerm .value ))
2020 })).filter (item => item .children && item .children .length > 0 )
2121})
2222
2323const input = useTemplateRef (' input' )
24- const value = ref (' ' )
24+ const isActiveSearch = computed (() => route .path .startsWith (' /docs/components' ))
25+ const searchTerm = ref (' ' )
26+
27+ watch (() => route .path , () => {
28+ if (! isActiveSearch .value ) {
29+ searchTerm .value = ' '
30+ }
31+ })
2532
2633defineShortcuts ({
2734 ' /' : {
@@ -39,8 +46,8 @@ defineShortcuts({
3946 <UPage >
4047 <template #left >
4148 <UPageAside >
42- <template v-if =" route . path . startsWith ( ' /docs/components ' ) " #top >
43- <UInput ref =" input" v-model =" value " variant =" soft" placeholder =" Filter..." class =" group" >
49+ <template v-if =" isActiveSearch " #top >
50+ <UInput ref =" input" v-model =" searchTerm " variant =" soft" placeholder =" Filter..." class =" group" >
4451 <template #trailing >
4552 <UKbd value =" /" variant =" subtle" class =" ring-muted bg-transparent text-muted" />
4653 </template >
You can’t perform that action at this time.
0 commit comments