Repository navigation
Hide Preview menu on small viewports and fix regression for FSE preview - #24537
Conversation
|
Size Change: +34 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
|
Nice. Before: After: From this testing shown above, though, you can see that the preview dropdown is only hidden when the mobile breakpoint is invoked. I wonder if it should be closed? I know that's a tougher thing to fix, and this improves the situation. But when the preview is open, focus is captured there, when it then gets hidden you can set focus elsewhere, and focus is no longer trapped inside when you go back. |
Good point @jasmussen! I'm investigating about a React based solution :) |
|
@jasmussen when you have time you cat take this again for a spin? :) |
|
This is working well for me! Focus is put on the body element when the menu is open and you resize the viewport. I'm not sure what the best practice for responsive design and focus management on disappearing elements is. Seems like it would be nice to set focus on the preview button, but that might also be overdoing it? Happy to defer to someone else. But as is, this seems to work better than it did a moment ago, and is an overall net improvement! |
|
Thanks for reviewing @enriquesanchez !
Open the is just one scenario of the many. In most cases the user might keep on doing things, and probably try to click the same button again, which now is just a link. Should we keep track of this change ( orientation ) and then track any new -cc @mcsf @youknowriad |
|
I think it's an open question. Focus lands on While it might be be luxurious to handle focus in the way outlined, it might also be shooting birds with cannons. Unless there's a use case I'm missing, in order to invoke this use case, you have to first click the preview dialog on a big window. Then you have to actively click outside the editing canvas to resize the window to close the popover. While resizing a window does not remove focus inside an active webpage, it does involve clicking elsewhere and then clicking back, at which point there's a great chance you'll set focus in a new place, or at least remove focus from where it was. My question is legitimate: is there a best practice for handling focus in responsive situations where an element gets removed from the DOM? Microsoft Word is not the best parallel or example or even representative necessarily of a best practice. But just as a quick test: no, they don't do anything to handle focus in responsive cases: |
|
Definitively an edge case, but I see this being a possible occurrence for someone using a hand-held device, like a phone, and also using a screen reader. In that scenario, the user doesn't need to click elsewhere (in which case I agree the focus has been intentionally moved by the user) but only tilt or rotate their device. The feeling of disorientation would probably be worse if you're using a screen-reader and don't perceive the layout changes on screen due to the device's orientation change. All of the sudden you find your focus somewhere else without knowing why. |
|
I don't believe there is a
I believe this could be discussed and addressed in a follow up PR, taking into account the current behaviour in Do you think this is a blocker for now @enriquesanchez? If yes, I should create a separate PR to fix a small |
|
@ntsekouras I don't think it's a blocker and this is definitively an improvement that addresses the initial issue. |




Description
Resolves: #24385
Also fixes a small regression from this PR: #24487, that hid the
Previewcomponent inFSE.