From a8a5c36142cfd8eed86b8a7e986e75c9ec0ad3b5 Mon Sep 17 00:00:00 2001 From: Ashvin-Sr Date: Fri, 5 Dec 2025 16:03:21 -0500 Subject: [PATCH] fix: update glossary.mdx to use encoded key when searching the DOM fix: remove stale entries in the DOM if they become null --- docs/docs/glossary.mdx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/docs/glossary.mdx b/docs/docs/glossary.mdx index cc1e594b43a..f3cff6f642a 100644 --- a/docs/docs/glossary.mdx +++ b/docs/docs/glossary.mdx @@ -30,7 +30,8 @@ export const GlossaryContent = () => { const scrollToRow = (topic, rowKey) => { const topicId = encodeURIComponent(topic); - const row = tableRefs.current[topicId]?.[rowKey]; + const encRowKey = encodeURIComponent(rowKey); + const row = tableRefs.current[topicId]?.[encRowKey]; if (row) { row.scrollIntoView({ behavior: 'smooth', block: 'center' }); row.classList.add('table-row-highlight'); @@ -86,9 +87,15 @@ export const GlossaryContent = () => { return { ref: (node) => { + if (!tableRefs.current[topicId]) tableRefs.current[topicId] = {}; if (node) { - if (!tableRefs.current[topicId]) tableRefs.current[topicId] = {}; tableRefs.current[topicId][record.key] = node; + } else { + // cleanup stale reference when row unmounts + delete tableRefs.current[topicId][record.key]; + if (Object.keys(tableRefs.current[topicId]).length === 0) { + delete tableRefs.current[topicId]; + } } }, };