diff --git a/ts/a11y/explorer/KeyExplorer.ts b/ts/a11y/explorer/KeyExplorer.ts index 2fe7c8591..c09c691c4 100644 --- a/ts/a11y/explorer/KeyExplorer.ts +++ b/ts/a11y/explorer/KeyExplorer.ts @@ -1941,10 +1941,29 @@ 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 stop + * the explorer from processing the click. + */ + protected addHtmlEvents() { + for (const html of Array.from(this.node.querySelectorAll('mjx-html'))) { + const stop = (event: Event) => { + if (html.contains(document.activeElement)) { + event.stopPropagation(); + } + }; + html.addEventListener('click', stop); + html.addEventListener('keydown', stop); + html.addEventListener('dblclick', stop); + } + } + /********************************************************************/ /* * Actions and links