Fix refocusing the selected node after a rerender.#1264
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 issues with refocusing the explorer after a re-render action occurs. In particular, when a menu action required a re-render (like when the speech settings change), the focus would go to the whole expression rather than the previously selected node. Moreover, because the speech isn't added until after a delay when the new expressions are rendered, and the focused element was in an old expression, when that is removed, the focus reverts to the last focused item (or the whole page), and so some screen readers would announce that previous item or the page itself before the new expression gets its speech and refocuses on the sub-expression again. For screen readers with separate focus/browse modes, it might also switch between modes (and announce that) in between as well, depending on the mode of the previously focused item.
This is fixed by adding a temporary item to the page that is used to hold the focus while the math is re-rendered. It has the same role as the
mjx-speechitems, and so the focus mode is retained. It has an aria label that contains the "none" content, so nothing is spoken when it is focused. When the re-rendering is complete, the temporary item is removed. This makes the transition between old and re-rendered expressions operate smoothly.The previous handling of
mactionelements did get the refocusing correct, but could suffer from the focus/browse mode issues, and announcing of another element during the re-rendering, and so it now uses this same work-around to make the transition.One other issue that is fixed here is that if an
mactionfrom the collapsible math extension is focused and the menu is used to select an item that does a page re-render, the refocusing went to the full expression. This is because themactionelements end up getting newidattributes, to thesemanticFocus()value is looking for the wrong element after the re-render. This issue is fixed here by having theComplexityMathItemsave the initialidvalue and restart the numbering there, so the ids will remain the same after the re-render. That allows the proper sub-expression to be focused after the re-rendering.The explorer's
state()function now stops the explorers (so the regions are removed) when the state is set to before when the explorer was inserted. The explorers aren't actually removed, however (technically they should be). They are reattached if the page is re-rendered.Some changes are made to the magnifier region to prevent the border outline (from the
mjx-selectedCSS) and to move the background color to the innerdivso that the color covers the complete magnifier region (rather than having a white border on top and bottom). Some changes in the menu code fix a problem with turning on the hover highlighting when the complexity code needs to be loaded.