File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ const sortedResults = computed(() => {
1616 return [... props .results .matches ].sort ((a , b ) => a .name .localeCompare (b .name ))
1717})
1818
19+ const hasResults = computed (() => props .results .matches .length > 0 )
20+
1921// Compute the results title based on the type of search
2022const resultsTitle = computed (() => {
21- if (props . results . matches . length === 0 ) {
23+ if (! hasResults . value ) {
2224 return ' No Results'
2325 }
2426
@@ -49,16 +51,19 @@ watch(() => props.results.matches.length, (newCount) => {
4951}, { immediate: true })
5052
5153const toggleExpand = () => {
52- isExpanded .value = ! isExpanded .value
53- emit (' update:expanded' , isExpanded .value )
54+ // Only allow toggling if there are results
55+ if (hasResults .value ) {
56+ isExpanded .value = ! isExpanded .value
57+ emit (' update:expanded' , isExpanded .value )
58+ }
5459}
5560 </script >
5661
5762<template >
5863 <div class =" search-results" :class =" { expanded: isExpanded }" >
5964 <div class =" results-header" @click =" toggleExpand" >
6065 <span class =" result-count" >{{ resultsTitle }}</span >
61- <button class =" expand-button" >
66+ <button v-if = " hasResults " class =" expand-button" >
6267 {{ isExpanded ? '▼' : '▲' }}
6368 </button >
6469 </div >
You can’t perform that action at this time.
0 commit comments