From e866ceb3407af990e17fd7a68c5cc946c682ec67 Mon Sep 17 00:00:00 2001 From: Robert Sese <734194+rsese@users.noreply.github.com> Date: Thu, 20 Jul 2023 13:53:45 -0500 Subject: [PATCH] update parent li display as well with minitoc links (#39386) --- components/article/ToolPicker.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/article/ToolPicker.tsx b/components/article/ToolPicker.tsx index decd54c5438c..6596b8b26d93 100644 --- a/components/article/ToolPicker.tsx +++ b/components/article/ToolPicker.tsx @@ -17,6 +17,14 @@ function showToolSpecificContent(tool: string, supportedTools: Array) { .filter((el) => supportedTools.some((tool) => el.classList.contains(tool))) .forEach((el) => { el.style.display = el.classList.contains(tool) ? '' : 'none' + + // hack: special handling for minitoc links -- we can't pass the tool classes + // directly to the Primer NavList.Item generated
  • , it gets passed down + // to the child . So if we find an that has the tool class and its + // parent is an
  • , we hide/unhide that element as well. + if (el.tagName === 'A' && el.parentElement && el.parentElement.tagName === 'LI') { + el.parentElement.style.display = el.classList.contains(tool) ? '' : 'none' + } }) // find all tool-specific *inline* elements and hide or show as appropriate