enhance(frontend): 設定検索時に対象が含まれるMkFolderを自動で開いておくように

This commit is contained in:
syuilo 2025-04-08 08:43:56 +09:00
parent e8758bf77d
commit 3d206d2a0f
2 changed files with 21 additions and 20 deletions

View file

@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div ref="root" :class="[$style.root, { [$style.highlighted]: highlighted }]">
<slot></slot>
<slot :isParentOfTarget="isParentOfTarget"></slot>
</div>
</template>
@ -39,9 +39,10 @@ const rootElMutationObserver = new MutationObserver(() => {
const injectedSearchMarkerId = inject(DI.inAppSearchMarkerId, null);
const searchMarkerId = computed(() => injectedSearchMarkerId?.value ?? window.location.hash.slice(1));
const highlighted = ref(props.markerId === searchMarkerId.value);
const isParentOfTarget = computed(() => props.children?.includes(searchMarkerId.value));
function checkChildren() {
if (props.children?.includes(searchMarkerId.value)) {
if (isParentOfTarget.value) {
const el = window.document.querySelector(`[data-in-app-search-marker-id="${searchMarkerId.value}"]`);
highlighted.value = el == null;
}