-
Notifications
You must be signed in to change notification settings - Fork 191
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
[Popup] focus anchor after hide? #327
Comments
One small nit here to my original issue, we should specify that focus returns to the previously-focused element (which in many cases will be the popup's anchor), unless the popup was hidden because the user expressly moved focus. This would align with a recent change to |
There hasn't been any discussion on this issue for a while, so we're marking it as stale. If you choose to kick off the discussion again, we'll remove the 'stale' label. |
Bringing this issue back up, as I've started to think about implementing this behavior for Popup. There are some differences between popup and dialog, and I'm not entirely sure what the right behavior is:
Suggestions/thoughts/input appreciated. Particularly from the a11y community. |
where focus goes in many cases will probably be similar across various types of For the general bits:
now, depending on the type of popup, and under the assumption a popup has not been made to trap focus - as one may be want to do - pressing the tab key would return focus to either:
For instance, the current On the flip side, many custom components (e.g., With all that said, and particularly in regards to the tab key, my opinion is that a general author defined Rather, a platform defined element which invokes a popup (e.g., the hopefully eventual |
@scottaohara thanks for the detailed response.
Quick point: this isn't true on a Mac with native
Ok, great, so it sounds like you think (in addition to your other points) that hitting Tab should move focus to the next focusable element in the DOM.
I'll defer to your judgement for So to summarize what you think should happen (correct me if I missed something):
In all cases, "return to previously focused element" should behave as it does for One last note about "last focused element" or "element that invoked the popup" - they should be the same. I.e. when an invoking element is activated to show a popup, it'll be the last focused element. |
That's true for chromium/webkit. Firefox behaves as I mentioned above / how the browsers behave on PC. 'think different' ;)
yes. that seems the safest default that authors could override if they so choose. And yes, for a particular component from the platform, they'd do what they will with tab key dismissal (including not allowing it at all, apparently :) ) |
@scottaohara awesome, thanks. I'm going to agenda+ this to hopefully get that resolved. |
Clarifying and adding a few things as I implement this: These actions cause focus to be returned to the previously-focused element:
These actions do not cause focus to be returned to the previously-focused element. Instead, the "normal" behavior happens for each action:
|
Here's another funny corner case:
I'm thinking the appropriate tweak would be to only set Another tweak to the above rules: I don't think focus should be returned/changed when hiding |
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3627159 Commit-Queue: Mason Freed <masonf@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1006180}
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3627159 Commit-Queue: Mason Freed <masonf@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1006180}
…nt on popup hide, a=testonly Automatic update from web-platform-tests Return focus to previously-focused element on popup hide Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3627159 Commit-Queue: Mason Freed <masonf@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1006180} -- wpt-commits: f4a6afa267e1d7aed8191b85c989c2eb54ad1b12 wpt-pr: 34116
…nt on popup hide, a=testonly Automatic update from web-platform-tests Return focus to previously-focused element on popup hide Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3627159 Commit-Queue: Mason Freed <masonf@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1006180} -- wpt-commits: f4a6afa267e1d7aed8191b85c989c2eb54ad1b12 wpt-pr: 34116
The Open UI Community Group just discussed
The full IRC log of that discussion<gregwhitworth> Topic: [Popup] focus anchor after hide?<gregwhitworth> github: https://github.com//issues/327 <gregwhitworth> masonf: focusing the previously focused element <gregwhitworth> masonf: in dialog, when you focus the dialog and when you close it or hide it focus moves to where you used to be <gregwhitworth> masonf: there seems to be a desire to do the same thing, although tthere are complications <gregwhitworth> masonf: for example when you light dismiss and click another button, but you wouldn't want to focus elsewhere when you move to another focusable element <gregwhitworth> masonf: you shouldn't jump to something else <gregwhitworth> masonf: there's a more complex scenarios when you have a stacked popup <gregwhitworth> masonf: you open a nested popup you don't want to pop back to the first thing because it would close the first popup <gregwhitworth> masonf: let's resolve to move to the prior focused element where it makes sense <JonathanNeal> +1 to returning focus to the popup (anchor?) when it “makes sense”. <masonf> Proposed resolution: focus the previously focused element when it makes sense. Handle the corner cases carefully, and define the behavior more precisely. <gregwhitworth> +1 with the caveat that the proposed resolution to define "where it makes sense" <dandclark> q+ <gregwhitworth> ack una <gregwhitworth> una: I would +1 as well and saw scotto_ +1 it in the issue <gregwhitworth> ack dandclark <gregwhitworth> dandclark: I agree with the stated resolution <gregwhitworth> dandclark: I'm a little worried about the complexity getting out of control <gregwhitworth> dandclark: I would think that each stacked popup would need its own idea of what is focused before me <gregwhitworth> dandclark: I guess I want to leave room to backing off if this is really complicated <JonathanNeal> +1 to the proposed resolution <gregwhitworth> masonf: I just want to say that I've already implemented this in Chromium <gregwhitworth> masonf: the thing I mentioned in the scenario for nested popups <gregwhitworth> dandclark: that makes me feel a lot better <masonf> q? <masonf> RESOLVED: focus the previously focused element when it makes sense. Handle the corner cases carefully, and define the behavior more precisely. <bkardell_> +1 |
Ok, per the resolution, I've written up what I believe to be the correct behavior in the explainer. See the PR here. It is essentially the behavior discussed in this comment plus this comment. And it is what I've already implemented in the Chromium prototype. I'm going to close this issue, but if anyone finds issues with the explainer description or the Chromium prototype behavior, please do file an issue here (or on https://crbug.com/new) and I'll take a look! |
Akin to <dialog>'s behavior, the desired behavior is that focus is returned to the previously-focused element when a popup is hidden: openui/open-ui#327 Bug: 1307772 Change-Id: Ia6ae1981612a0c0150b8b5f51b485a00a9a90de9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3627159 Commit-Queue: Mason Freed <masonf@chromium.org> Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1006180} NOKEYCHECK=True GitOrigin-RevId: f1e305a9f30be10bebbe48a83aa104bbcd85db7f
On MicrosoftEdge/MSEdgeExplainers#441, @carmacleod mentioned:
This seems like a good behavior from a usability/accessibility perspective, assuming that the popup didn't dismiss because the user moved focus out of the popup explicitly.
The text was updated successfully, but these errors were encountered: