From 9cf6b542e28962aefe9786b15082a30b92275094 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 3 Jan 2026 08:45:02 -0500 Subject: [PATCH 1/4] Allow clicking in HTML-in-MathML to activate elements rather than cause selection in the explorer. (mathjax/MathJax#3491) --- ts/a11y/explorer/KeyExplorer.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ts/a11y/explorer/KeyExplorer.ts b/ts/a11y/explorer/KeyExplorer.ts index 2fe7c85918..b1151cfb16 100644 --- a/ts/a11y/explorer/KeyExplorer.ts +++ b/ts/a11y/explorer/KeyExplorer.ts @@ -1941,10 +1941,26 @@ export class SpeechExplorer public AddEvents() { if (!this.eventsAttached) { super.AddEvents(); + this.addHtmlEvents(); this.eventsAttached = true; } } + /** + * Prevent clicks in mjx-html nodes from propagating (so clicks in + * HTML input elements or other selectable nodes will not cause + * the explorer from processing the click. + */ + protected addHtmlEvents() { + for (const html of Array.from(this.node.querySelectorAll('mjx-html'))) { + html.addEventListener('click', (event) => { + if (html.contains(document.activeElement)) { + event.stopPropagation(); + } + }); + } + } + /********************************************************************/ /* * Actions and links From eb066fce753d1c724ca3773ae73d823c6127460e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 6 Jan 2026 08:53:31 -0500 Subject: [PATCH 2/4] Updates to allow keydown and dblclick events to pass through to HTML elements as well --- ts/a11y/explorer/KeyExplorer.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ts/a11y/explorer/KeyExplorer.ts b/ts/a11y/explorer/KeyExplorer.ts index b1151cfb16..acda8f1fdb 100644 --- a/ts/a11y/explorer/KeyExplorer.ts +++ b/ts/a11y/explorer/KeyExplorer.ts @@ -1953,11 +1953,14 @@ export class SpeechExplorer */ protected addHtmlEvents() { for (const html of Array.from(this.node.querySelectorAll('mjx-html'))) { - html.addEventListener('click', (event) => { + const stop = (event: Event) => { if (html.contains(document.activeElement)) { event.stopPropagation(); } - }); + }; + html.addEventListener('click', stop); + html.addEventListener('keydown', stop); + html.addEventListener('dblclick', stop); } } From b5382589fdd337e043e4326a87e3c6d50ce00c28 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 7 Jan 2026 07:10:40 -0500 Subject: [PATCH 3/4] Update ts/a11y/explorer/KeyExplorer.ts Co-authored-by: Volker Sorge --- ts/a11y/explorer/KeyExplorer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/a11y/explorer/KeyExplorer.ts b/ts/a11y/explorer/KeyExplorer.ts index acda8f1fdb..0e22873c60 100644 --- a/ts/a11y/explorer/KeyExplorer.ts +++ b/ts/a11y/explorer/KeyExplorer.ts @@ -1947,7 +1947,7 @@ export class SpeechExplorer } /** - * Prevent clicks in mjx-html nodes from propagating (so clicks in + * Prevent clicks in mjx-html nodes from propagating, so clicks in * HTML input elements or other selectable nodes will not cause * the explorer from processing the click. */ From 44af203f0d598a415ed1f70c59a9bd6f71a5ee8b Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 7 Jan 2026 07:11:18 -0500 Subject: [PATCH 4/4] Update ts/a11y/explorer/KeyExplorer.ts Co-authored-by: Volker Sorge --- ts/a11y/explorer/KeyExplorer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/a11y/explorer/KeyExplorer.ts b/ts/a11y/explorer/KeyExplorer.ts index 0e22873c60..c09c691c4d 100644 --- a/ts/a11y/explorer/KeyExplorer.ts +++ b/ts/a11y/explorer/KeyExplorer.ts @@ -1948,7 +1948,7 @@ export class SpeechExplorer /** * Prevent clicks in mjx-html nodes from propagating, so clicks in - * HTML input elements or other selectable nodes will not cause + * HTML input elements or other selectable nodes will stop * the explorer from processing the click. */ protected addHtmlEvents() {