Skip to content

Commit a9a3fc0

Browse files
authored
Merge pull request #1410 from mathjax/issue3491
Allow clicking in HTML-in-MathML to activate elements rather than cause selection in the explorer. (mathjax/MathJax#3491)
2 parents ba1cf66 + 44af203 commit a9a3fc0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,10 +1941,29 @@ 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 stop
1952+
* the explorer from processing the click.
1953+
*/
1954+
protected addHtmlEvents() {
1955+
for (const html of Array.from(this.node.querySelectorAll('mjx-html'))) {
1956+
const stop = (event: Event) => {
1957+
if (html.contains(document.activeElement)) {
1958+
event.stopPropagation();
1959+
}
1960+
};
1961+
html.addEventListener('click', stop);
1962+
html.addEventListener('keydown', stop);
1963+
html.addEventListener('dblclick', stop);
1964+
}
1965+
}
1966+
19481967
/********************************************************************/
19491968
/*
19501969
* Actions and links

0 commit comments

Comments
 (0)