Skip to content

Commit e220960

Browse files
authored
simplify scrollToFirstVisibleMatch
1 parent 9bd7b80 commit e220960

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

src/resources/projects/website/search/quarto-search.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,16 +1260,10 @@ function openAllTabsetsContainingEl(el) {
12601260

12611261
function scrollToFirstVisibleMatch(mainEl) {
12621262
for (const mark of mainEl.querySelectorAll("mark")) {
1263-
let hidden = false;
1264-
let el = mark.parentElement;
1265-
while (el && el !== mainEl) {
1266-
if (el.classList.contains("tab-pane") && !el.classList.contains("active")) {
1267-
hidden = true;
1268-
break;
1269-
}
1270-
el = el.parentElement;
1271-
}
1272-
if (!hidden) {
1263+
const isMarkVisible = matchAncestors(mark, '.tab-pane').every(markTabPane =>
1264+
markTabPane.classList.contains("active")
1265+
)
1266+
if (isMarkVisible) {
12731267
mark.scrollIntoView({ behavior: "smooth", block: "center" });
12741268
return;
12751269
}

0 commit comments

Comments
 (0)