Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggering links from the explorer. #687

Merged
merged 2 commits into from
Apr 22, 2021
Merged

Triggering links from the explorer. #687

merged 2 commits into from
Apr 22, 2021

Conversation

zorkow
Copy link
Member

@zorkow zorkow commented Apr 21, 2021

Hitting return on the node that announces itself to be a link will trigger the link.
Unfortunately, this only works for CHTML, not in SVG.

I've tried by setting focus on the anchor element and continue propagating the event.
Unfortunately, that only works sporadically.

Also dispatching a new event like below did not do the trick.

      let event = new KeyboardEvent('keydown', {code: '13', bubbles: true});
      node.parentElement.dispatchEvent(event);

@zorkow zorkow requested a review from dpvc April 21, 2021 19:29
match(/(^| )link($| )/);
if (focus) {
// Works for CHTML only.
node.parentElement.click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW in the light walker, I basically set window.location.href to the href I get from the link.

@dpvc
Copy link
Member

dpvc commented Apr 21, 2021

Also dispatching a new event like below did not do the trick.

It looks like

      node.parentNode.dispatchEvent(new MouseEvent('click'));

works for me, at least in Firefox (provided node.parentNode is the <a> node).

@zorkow
Copy link
Member Author

zorkow commented Apr 22, 2021

Thanks. I was clearly in the keyboard zone, as I had also experimented with new Event('click'), which did not work. D'oh!

@zorkow zorkow marked this pull request as ready for review April 22, 2021 11:58
@zorkow
Copy link
Member Author

zorkow commented Apr 22, 2021

This is now ready for review.

@zorkow
Copy link
Member Author

zorkow commented Apr 22, 2021

PS: This is the first time I am using optional chaining in MathJax code, as @pkra suggested it the other day.
It seems to be supported by all major browsers by now and the code transpiled by Typescript seems to be at least as fast as traditional boolean tests.

@zorkow zorkow changed the title Triggering links from the explorer in CHTML. Triggering links from the explorer. Apr 22, 2021
Copy link
Member

@dpvc dpvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'll merge.

@dpvc dpvc merged commit e77bee5 into develop Apr 22, 2021
@dpvc dpvc deleted the a11y_explorer_links branch April 22, 2021 13:58
@dpvc dpvc added this to the 3.1.3 milestone Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants