diff --git a/docs/src/modules/components/MarkdownLinks.js b/docs/src/modules/components/MarkdownLinks.js
index <HASH>..<HASH> 100644
--- a/docs/src/modules/components/MarkdownLinks.js
+++ b/docs/src/modules/components/MarkdownLinks.js
@@ -28,11 +28,18 @@ export async function handleEvent(event, as) {
   document.body.focus();
 }
 
+/**
+ * @param {MouseEvent} event
+ */
 function handleClick(event) {
-  const activeElement = document.activeElement;
+  let activeElement = event.target;
+  while (activeElement?.nodeType === Node.ELEMENT_NODE && activeElement.nodeName !== 'A') {
+    activeElement = activeElement.parentElement;
+  }
 
   // Ignore non link clicks
   if (
+    activeElement === null ||
     activeElement.nodeName !== 'A' ||
     activeElement.getAttribute('target') === '_blank' ||
     activeElement.getAttribute('data-no-link') === 'true' ||
@@ -41,7 +48,7 @@ function handleClick(event) {
     return;
   }
 
-  handleEvent(event, document.activeElement.getAttribute('href'));
+  handleEvent(event, activeElement.getAttribute('href'));
 }
 
 let bound = false;
[docs] Fix links being opened when dismissing context menus (#<I>)