-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Can showPicker() focus a control? #9757
Comments
Is this a platform limitation or is this something that could be addressed within WebKit? Either way if it's a requirement for |
It's a feature of iOS, as I understand it. |
How does |
Currently input.showPicker() doesn't work on iOS except for file inputs. So this spec change would be needed in order to implement it (as far as I understand) |
I've confirmed that it does appear to be a requirement for iOS. I personally think it's absolutely fine to focus where required. Would this require a clarification in the spec or would getting verbal confirmation here enough? |
Feedback from @jcsteh and @anna-yeddi -
The spec should require to move focus. I guess it should also (attempt to) move focus for |
This would be a "breaking" change for inputs. I've got no idea if that'd actually be a problem but I'm curious if there's a specific known issue with how it's currently implemented? |
@mfreed7 @annevk would updating the spec to forcefully move focus always instead of just when needed by the platform be acceptable to you? I don't mind either way for select. But for input it would be a change in behaviour from current implementations? I'd also be curious on the accessibility reasoning for it? Because shouldn't the end result of |
Yeah focusing the picker, and not the input, seems like the right thing. When closing/dismissing the picker, should focus go back to whatever previously had focus, or to the control that has the picker (if it's visible)? |
Ah so to clarify this issue is regarding whether the input itself is allowed to be focused as part of this method. On iOS you have to focus the input to then load the picker. I think the spec should say it can optionally focus the input before the picker where required by the platform. And return focus would go back to either the input in iOS case or the previously focused element (such as a button) in other cases? |
From an accessibility perspective, focusing the picker is the really important part. Unless I'm missing something, the spec doesn't currently require the picker to be "focused". It just needs to be "displayed"/"shown", which is a subtle but important distinction. So, I think the spec should say (not intended to be actual spec wording):
|
Note that the spec for showPicker() right now works for elements which are not connected to the DOM. So they cannot be focused. I suspect that is actually the majority use case. |
That's somewhat unfortunate for something like a date input, where the ability to type a date might be far more efficient for some users than using the picker. But that's probably getting out of scope for this particular issue. |
@domenic makes sense, but that only applies to |
No, it applies to all pickers? Demo with date picker: https://boom-bath.glitch.me/pickers-3.html
In general I think the spec seems reasonable as-is, and I'm not sure where this focus requirement is coming from... I agree with other comments upthread that focusing the picker is a good idea, but focusing the element whose existence helps show the picker seems counterproductive. The user wants to manipulate the picker, not the element! |
Interesting, though that only seems to work in Chromium. I guess there are no tests for that particular behavior? Also, the specification doesn't make it clear where to show the picker in such cases. Is it relative to the click in some way? Presumably you'd want that to be configurable? |
Should we leave this issue open for further discussion cause I agree the offscreen input use case is important (iOS may not allow it other than for file inputs though). And get the select in without mentioning focus for now? |
Currently Chrome seems to go with 0,0 which doesn't seem great. As you say Firefox doesn't show anything at all. Safari doesn't currently support showPicker() for date inputs but iirc my PR to add it would probably behave like Firefox. |
Regardless of whether we focus the control itself, it's important that the picker gets focus for accessibility. I'm guessing you were talking about focus for the control itself, but I think it's important that the spec covers focusing the picker at the very least. |
@jcsteh I've added the above mentioned line to the spec PR |
That doesn't work, those UI elements are not focusable areas currently I think. I'm also not sure it makes sense to expand this feature while it apparently isn't implemented as intended in Gecko or WebKit, and there's no way to pick a position for the UI element in the user agent that does implement it as intended. |
I meant to come back and say WebKit currently doesn't focus the picker UI instead keyboard navigating of the input is done through the input element itself (at least for date inputs). Have removed that mention of focus as a result. In terms of how to proceed I'll leave that up to spec editors. I think there's still value even if it doesn't include elements outside the DOM being triggered (for example the issue that sparked the PR would be addressed). |
This can maybe be folded into the more general issue around how Possibly we want to run "focusing steps" but that'd require adding these pickers as focusable areas somehow. |
Fwiw both Chrome and Firefox's (on desktop) pickers are currently keyboard navigable I think it's just Safari where that might be difficult due to the usage of native UI. |
If the picker is inside of another element (ex: overlay), focus should shift automatically to the picker itself if it is the first interactive element. Once the picker is opened, focus should go to the first element contained therin. If focus is returned to the picker, and the picker is opened, then focus should go to the currently selected element. |
Hi all. Paraphrasing TAG's design review comment here, to ask you if there have been any developments... TAG feels that consistency between the behaviour of We noted the discussion on this thread, as to whether the control, or the picker, should be focused by default. Does that mean that the behavior of It's important to have a clear idea of the expected use cases. Are there any use cases that require the control/picker to be focused? (We could think of some, but we're keen to gauge what the development community may want to do with this feature.) How easy the default behavior is to escape is also a factor. If the picker is focused by default, can authors get the alternate behavior by running |
real world use-case that I just ran into then found this thread. I think this is something prevalent with design system work in which the select is wrapped as part of another designed asset / larger library. issue I just ran into
riffing as to my expectationsI would think that Tour edge case vs typical use-caseIf I was to do a tour, that would imply that
In this way we'd need something similar where
Another possibility would be that |
Hi all, just wondering if this is still the right place to be discussing this issue, or if there's some other thread we should be following too? TAG is interested in following developments. |
On iOS a control cannot show its picker without having focus. Should the web developer handle that or should
showPicker()
handle it for them? The latter seems somewhat reasonable given the current description ofshowPicker()
(in particular the last step of "show the picker, if applicable"), but this would be worth calling out explicitly given the additional events that would end up firing.Thoughts?
The text was updated successfully, but these errors were encountered: