Skip to content

Commit

Permalink
refactor(sidebar-filter): rename target => container
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Jun 6, 2023
1 parent 3d30de5 commit 1255bc2
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions client/src/document/organisms/sidebar/SidebarFilterer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,23 @@ export class SidebarFilterer {
// Show/hide items (+ show parents).
const terms = splitQuery(query);
let matchCount = 0;
this.items.forEach(
({ haystack, link, container: target, heading, parents }) => {
this.resetHighlighting(link);
const isMatch = terms.every((needle) => haystack.includes(needle));

this.toggleElement(target, isMatch);

if (isMatch) {
matchCount++;
this.highlightMatches(link, terms);
if (heading) {
this.showHeading(heading);
}
for (const parent of parents) {
this.expandParent(parent);
}
this.items.forEach(({ haystack, link, container, heading, parents }) => {
this.resetHighlighting(link);
const isMatch = terms.every((needle) => haystack.includes(needle));

this.toggleElement(container, isMatch);

if (isMatch) {
matchCount++;
this.highlightMatches(link, terms);
if (heading) {
this.showHeading(heading);
}
for (const parent of parents) {
this.expandParent(parent);
}
}
);
});

return matchCount;
}
Expand Down

0 comments on commit 1255bc2

Please sign in to comment.