Skip to content

Commit 9cf6b54

Browse files
committed
Allow clicking in HTML-in-MathML to activate elements rather than cause selection in the explorer. (mathjax/MathJax#3491)
1 parent 82cabf4 commit 9cf6b54

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,10 +1941,26 @@ export class SpeechExplorer
19411941
public AddEvents() {
19421942
if (!this.eventsAttached) {
19431943
super.AddEvents();
1944+
this.addHtmlEvents();
19441945
this.eventsAttached = true;
19451946
}
19461947
}
19471948

1949+
/**
1950+
* Prevent clicks in mjx-html nodes from propagating (so clicks in
1951+
* HTML input elements or other selectable nodes will not cause
1952+
* the explorer from processing the click.
1953+
*/
1954+
protected addHtmlEvents() {
1955+
for (const html of Array.from(this.node.querySelectorAll('mjx-html'))) {
1956+
html.addEventListener('click', (event) => {
1957+
if (html.contains(document.activeElement)) {
1958+
event.stopPropagation();
1959+
}
1960+
});
1961+
}
1962+
}
1963+
19481964
/********************************************************************/
19491965
/*
19501966
* Actions and links

0 commit comments

Comments
 (0)