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

include a11y in default settings, and fix a number of problems with changing menu values. (mathjax/MathJax#3310) #1169

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Nov 21, 2024

This PR fixes a number of problems that occur when menu values are changed, and in particular, when the menu values are reset to their defaults.

The fixes include the following:

  1. Resetting the menu to default values should force the math to be retypeset, but instead caused the math to disappear. This was due to the initial typesetting not setting the MathJax.startup.rerenderPromise, so that has been added, here.

  2. Turning off inline breaking would not remove the current inline breaks. This was due to the fact the inline breaks are handled via properties of the internal MathML nodes, and they were not being cleared. This PR adds code to clear those properties. It also moves the marker that the math has inline breaks from the outputData object (which is cleared when the state is set to before the math is rendered, so the flag was being lost) to a property of the top-level math node.

  3. In the past, a menu that is produced by a mouse click (rather than pressing space on a focused expression) could cause the expression to become focused even when it has been re-rendered, which could leave the expression in a partially active state. We add a refocus property to the MJContextMenu class to track whether we should refocus the expression or not. This requires a little trickery because there is no easy way to tell mj-context-menu not to call store.active.focus() during the unpost() method for the menu. A better solution would be to add a feature to mj-context-menu to control that (say via an argument to unpost())

  4. Finally, the a11y options weren't being reset by the "reset to defaults" menu item because the values being reset where based on the keys of the menu.settingsobject. This PR changes that to use the defaultSettings keys instead, and to include the a11y values in the defaultSettings object. Because the explorer can be loaded dynamically (it it is not included in the combined component, or if individual components are loaded separately), the defaultSettings may need to be augmented when the explorer is loaded.

  5. The reset code was changes to only reset the values that have changed, and to prevent multiple re-renderings of the document during the reset.

This resolves issue mathjax/MathJax#3310, and fixes several other items not indicated there.

@dpvc dpvc requested a review from zorkow November 21, 2024 21:00
@dpvc dpvc added this to the v4.0 milestone Nov 21, 2024
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.

1 participant