include a11y in default settings, and fix a number of problems with changing menu values. (mathjax/MathJax#3310) #1169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.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.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 theMJContextMenu
class to track whether we should refocus the expression or not. This requires a little trickery because there is no easy way to tellmj-context-menu
not to callstore.active.focus()
during theunpost()
method for the menu. A better solution would be to add a feature tomj-context-menu
to control that (say via an argument tounpost()
)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 themenu.settings
object. This PR changes that to use thedefaultSettings
keys instead, and to include thea11y
values in thedefaultSettings
object. Because the explorer can be loaded dynamically (it it is not included in the combined component, or if individual components are loaded separately), thedefaultSettings
may need to be augmented when the explorer is loaded.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.