From 5a5f0b8de95b95827d7ee83c3057429e4afa7836 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 9 Mar 2024 15:07:51 +0000 Subject: [PATCH] Page Display: Fixed highlighting for elements in nested details For #4878 --- resources/js/services/util.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/js/services/util.js b/resources/js/services/util.js index 59affff88..942456d9d 100644 --- a/resources/js/services/util.js +++ b/resources/js/services/util.js @@ -31,9 +31,12 @@ export function debounce(func, waitMs, immediate) { export function scrollAndHighlightElement(element) { if (!element) return; - const parentDetails = element.closest('details'); - if (parentDetails && !parentDetails.open) { - parentDetails.open = true; + let parent = element; + while (parent.parentElement) { + parent = parent.parentElement; + if (parent.nodeName === 'DETAILS' && !parent.open) { + parent.open = true; + } } element.scrollIntoView({behavior: 'smooth'});