Skip to content

Commit 4961598

Browse files
PR Feedback
1 parent 9c8f605 commit 4961598

File tree

1 file changed

+13
-4
lines changed
  • EssentialCSharp.Web/wwwroot/js

1 file changed

+13
-4
lines changed

EssentialCSharp.Web/wwwroot/js/site.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
markRaw,
77
watch,
88
computed,
9+
watchEffect
910
} from "vue";
1011
import { useWindowSize } from "vue-window-size";
1112

@@ -238,8 +239,8 @@ const app = createApp({
238239
const searchQuery = ref('');
239240

240241
const filteredTocData = computed(() => {
241-
expandedTocs.clear();
242242
if (!searchQuery.value) {
243+
expandedTocs.clear();
243244
return tocData;
244245
}
245246
const query = normalizeString(searchQuery.value);
@@ -252,12 +253,20 @@ const app = createApp({
252253
const childMatches = item.items.some(child => filterItem(child, query));
253254
matches = matches || childMatches;
254255
}
255-
if (matches) {
256-
expandedTocs.add(item.key); // Add matching item to expandedTocs
257-
}
258256
return matches;
259257
}
260258

259+
watchEffect(() => {
260+
expandedTocs.clear();
261+
const query = normalizeString(searchQuery.value);
262+
tocData.forEach(item => {
263+
if (filterItem(item, query)) {
264+
expandedTocs.add(item.key);
265+
console.log("Added ", item.key);
266+
}
267+
});
268+
});
269+
261270
function normalizeString(str) {
262271
return str.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " ").toLowerCase();
263272
}

0 commit comments

Comments
 (0)