-
Notifications
You must be signed in to change notification settings - Fork 20
C2LC-316: Fix focus trap settings for actions simplification menu toggle. #135
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
C2LC-316: Fix focus trap settings for actions simplification menu toggle. #135
Conversation
After our pairing session yesterday, I went further down the road with using references, and hit a few roadblocks. Using After wrestling with a few variations, I ended up using an approach similar to our modal, i.e. when the menu is open, a large transparent element is positioned to fill the screen, just behind the menu itself. Clicking anywhere outside the menu closes the menu and also removes the transparent element to avoid side effects. I also made a first pass at ensuring that the first checkbox in the panel is focused when the menu is open. I could use help with the polish on this, the focus works as expected when opening the menu with the keyboard, but when clicking the toggle with a mouse, the focus seems to move but the highlighting is wrong in Chrome. |
In later review, I figured out a few more things:
I could still use help on getting the first item to properly steal focus when the toggle is clicked (it works on key down). Otherwise, this is ready for review. |
As discussed in the chats, it seems like the focus position moves when you click the toggle using the mouse. Even though there are no
Oddly, if you hit a key such as caps lock, shift, arrows, the focus highlighting will appear on the correct element. |
I'm seeing an issue on Firefox on Windows (which isn't happening on Chrome on Windows): when I open the menu using the spacebar, the spacebar key press toggles the first item in addition to opening the menu. |
@the-t-in-rtf Could you expand a little on the point above: "If I reuse the global focus trap manager, it's unusable as it gets flagged as inactive by the program block editor. So we do need to use our own." Thanks. |
I may have the wrong idea here, but in my debugging sessions, I could see that by the time I was hitting a key in the actions menu, the focus trap manager's After debugging the calls to We would need similar logic in the actions menu, to ensure that we don't end up deactivating the focus trap manager when the action panel needs it. |
From chats with @sbates-idrc:
In other messages, Simon also noted that if you activate the menu by pressing the space key on Firefox in Windows, the first item gets toggled, which I verified as well on the Mac. Given this side effect, I think Simon's argument above for removing the "focus on first" logic is even stronger. To answer the question, yes, now we use a click on an external element to close the menu, so we don't have a good reason to fiddle with the focus, and I agree that it's to be avoided if possible. I will update the pull accordingly, and see if my idea about using the global focus trap manager works as well. |
…agement strategies.
I removed the focus manipulation code and other leftover bits from previous approaches. The issues with the spacebar no longer happen in Firefox.
With the approach I proposed, the shared focus trap manager remains active, which is good, but there's a side effect, suddenly every tab key moves forward two items (and every shift+tab moves backwards by two items), which makes every other checkbox unreachable. I pushed up the latest changes without the shared focus trap manager changes, so that the pull would be otherwise merge-ready. It only takes a minute to refactor, we can pair on it and look at it together if you want. |
@the-t-in-rtf I removed some more code that is no longer needed: sbates-idrc@e37d40d Please take a look and let me know if it looks good. I will then merge. Thanks. |
@sbates-idrc, thanks for catching that, looks fine to me. |
@sbates-idrc, I merged in your changes and updated with |
See C2LC-316 for details.