feat: Tag search will now only show the direct tag results instead of also showing the parent and siblings (#2906)

This commit is contained in:
Aman Harwara
2025-06-24 12:32:27 +05:30
committed by GitHub
parent c050a2cd33
commit caa8eff216
5 changed files with 63 additions and 14 deletions

View File

@@ -38,8 +38,11 @@ export function itemMatchesQuery(
searchQuery: SearchQuery,
collection: ReferenceLookupCollection,
): boolean {
const shouldCheckForSomeTagMatches = searchQuery.shouldCheckForSomeTagMatches ?? true
const itemTags = collection.elementsReferencingElement(itemToMatch, ContentType.TYPES.Tag) as SNTag[]
const someTagsMatches = itemTags.some((tag) => matchResultForStringQuery(tag, searchQuery.query) !== MatchResult.None)
const someTagsMatches =
shouldCheckForSomeTagMatches &&
itemTags.some((tag) => matchResultForStringQuery(tag, searchQuery.query) !== MatchResult.None)
if (itemToMatch.protected && !searchQuery.includeProtectedNoteText) {
const match = matchResultForStringQuery(itemToMatch, searchQuery.query)

View File

@@ -5,6 +5,7 @@ import { SearchableItem } from './SearchableItem'
export type SearchQuery = {
query: string
includeProtectedNoteText: boolean
shouldCheckForSomeTagMatches?: boolean
}
export interface ReferenceLookupCollection {