Page Display: Fixed highlighting for elements in nested details

For #4878
This commit is contained in:
Dan Brown 2024-03-09 15:07:51 +00:00
parent 8e01345f14
commit 5a5f0b8de9
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -31,9 +31,12 @@ export function debounce(func, waitMs, immediate) {
export function scrollAndHighlightElement(element) { export function scrollAndHighlightElement(element) {
if (!element) return; if (!element) return;
const parentDetails = element.closest('details'); let parent = element;
if (parentDetails && !parentDetails.open) { while (parent.parentElement) {
parentDetails.open = true; parent = parent.parentElement;
if (parent.nodeName === 'DETAILS' && !parent.open) {
parent.open = true;
}
} }
element.scrollIntoView({behavior: 'smooth'}); element.scrollIntoView({behavior: 'smooth'});