Skip to content
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

Consume user activation in show the picker #10344

Merged
merged 2 commits into from
May 28, 2024

Conversation

CanadaHonk
Copy link
Member

@CanadaHonk CanadaHonk commented May 13, 2024

More in-depth alternative to #10098. Fixes #10084, helps GHSA-hr74-5fj7-jgxp. cc @zcorpan @lukewarlow @josepharhar @domenic @annevk

(See WHATWG Working Mode: Changes for more details.)


/input.html ( diff )

More in-depth alternative to whatwg#10098. Fixes whatwg#10084, helps GHSA-hr74-5fj7-jgxp.
@CanadaHonk CanadaHonk marked this pull request as ready for review May 16, 2024 08:16
@josepharhar
Copy link
Contributor

This seems to accurately describe what I implemented in chromium here, so I am supportive: https://chromium-review.googlesource.com/c/chromium/src/+/5235516

@lukewarlow
Copy link
Member

@josepharhar one key difference is that this applies to the main algorithm not just the showPicker() function. So there's a difference here from your patch.

@josepharhar
Copy link
Contributor

Ah ok, I can see that calling element.click() on <input type=color> currently opens the picker, so if we made it check for and consume user activation, that could be a breaking change. Calling element.click() on <select> doesn't seem to currently do anything though.

I think it would probably be a good idea to make that require user activation though since it opens a popup document. I can guard the change behind a flag and revert it if websites are relying too much on it or something.

Let's do it!

The WPT should probably test the element.click() cases, right? This algorithm does get called when doing element.click(), right?

@CanadaHonk
Copy link
Member Author

The WPT should probably test the element.click() cases, right? This algorithm does get called when doing element.click(), right?

Yes and yes

@lukewarlow
Copy link
Member

My only concern with this is, stylable select will be a popover so does it really need to be concerned with user activation? Is it possible we should scope this to just pickers that can escape the bounds (current select and file?). Either way I think that's a concern we can address in future, just wanted to point it out.

@josepharhar
Copy link
Contributor

My only concern with this is, stylable select will be a popover so does it really need to be concerned with user activation?

No it shouldn't, and you can just call showPopover() on the datalist element. However, stylable select doesn't exist in the spec yet (hopefully it will someday), and if that really is an issue, then we can patch the algorithm to check whether it's in appearance:base-select mode or not.

Is it possible we should scope this to just pickers that can escape the bounds (current select and file?)

<input type=color> escapes the window bounds on chrome on linux.

My only concern is still that we would break existing websites, so I would launch the change behind a flag and disable+revert it if we get a lot of feedback about it.

@evilpie
Copy link

evilpie commented May 22, 2024

For consistency and safety we should apply this to everything. For example in Firefox the <input type=date> date picker can also extend outside the browser window.

@CanadaHonk
Copy link
Member Author

WPT PR: web-platform-tests/wpt#46502

CanadaHonk added a commit to CanadaHonk/wpt that referenced this pull request May 27, 2024
CanadaHonk added a commit to CanadaHonk/wpt that referenced this pull request May 27, 2024
@annevk
Copy link
Member

annevk commented May 28, 2024

No it shouldn't, and you can just call showPopover() on the datalist element.

What if there's no datalist element? I suspect this needs some more work. In particular as forcing style resolution also doesn't seem ideal. But that all can indeed be done at a later stage.

source Show resolved Hide resolved
@annevk
Copy link
Member

annevk commented May 28, 2024

I suspect we probably want this documented on MDN in due course so please file an issue. Also seems good to file bugs against Chromium and WebKit for this.

@CanadaHonk
Copy link
Member Author

Filed bugs for vendors and MDN. Are there any other blockers for this merging at the moment?

annevk pushed a commit to web-platform-tests/wpt that referenced this pull request May 28, 2024
@annevk annevk merged commit 71eee30 into whatwg:main May 28, 2024
2 checks passed
@annevk
Copy link
Member

annevk commented May 28, 2024

Thanks @CanadaHonk for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Should showPicker() consume user activation?
5 participants