0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-25 05:02:57 +01:00

Minimap - Ensure that we correctly handle not found matched elements

- Currently the code appears to try to fallback to an empty id, however this will never happen as we are building a non-empty string
- Instead if we have not found any closest panel, simply return the intersection map as is
Closes #11210
This commit is contained in:
LB Johnston 2023-11-10 06:17:41 +10:00 committed by LB (Ben Johnston)
parent 901895c8d3
commit 0f44abeef2

View File

@ -38,8 +38,9 @@ const mapIntersections = (
acc: LinkIntersections,
{ target, isIntersecting }: IntersectionObserverEntry,
) => {
const href = `#${target.closest('[data-panel]')?.id}` || '';
acc[href] = isIntersecting;
const id = target.closest('[data-panel]')?.id;
if (!id) return acc;
acc[`#${id}`] = isIntersecting;
return acc;
};