Closed Roy-Orbison closed 3 years ago
The CSS Working Group just discussed [css-selectors] Can you standardise a pseudo-element selector for file inputs?
, and agreed to the following:
RESOLVED: expose this selector and name it ::file-chooser
RESOLVED: expose this selector and name it ::file-chooser button
Can we get an anatomy definition for this in Open UI. The primary purpose of this site is to begin defining the actual pieces of the control from a functional perspective and align across the industry. I can help someone out here. Let me know if you'd like to setup 30 minutes to get it rolling. For the file input anatomy itself it shouldn't take too long.
Here's the contribution docs: https://open-ui.org/contribute
I'm really happy we made a clear and quick decision on the call we just had. Also, perhaps the name needs a bit of additional consideration? Testing, really... test the name with Authors to make sure we make the right call. So I tweeted: https://twitter.com/jensimmons/status/1263142931034234886 to see what Authors think.
Thanks @jensimmons - only reason I want some research done is to ensure that we aren't standardizing ourselves into a corner. Since there is a web compat hit this may be fine but in our peeling of the <select>
onion and some other controls there are often usecases that are lost due to cementing what's there at first glance. Again, not saying that the resolution is wrong I just want to ensure we're not missing a valid usecase that may require an additional psuedo/anatomy design or other way of thinking about the problem. Thanks @emilio for your willingness to take an initial stab at the research/proposal page in Open UI. Again, happy to lend a hand where necessary.
@gregwhitworth here's my initial draft. The good thing is that all the systems listed there which have file inputs have a button of sorts, fwiw.
So I think this is pretty sensible over-all.
Should this be a tree-abiding pseudo?
Probably.
I will note that there are a lot more search results for "file picker" than "file chooser". And also most of the ones for "file chooser" in quotes seem to be about some Java thing...
And yes, it's a tree-abiding pseudo.
I will note that there are a lot more search results for "file picker" than "file chooser". And also most of the ones for "file chooser" in quotes seem to be about some Java thing...
"file upload" is way ahead in search volume when coupled with either css, or button. As I wrote in the WICG draft thread:
I agree with the
-button
suffix as the selector's purpose essentially dictates it. However, for consistency's sake, the verb really should be a choice between "upload" and "select"/"selector". The majority of standards documents for HTML and JavaScript refer to such controls as file upload, and the action performed as selection, and have done so for many years. What benefit is there to CSS authors in deviating from those conventions?There is merit to each:
- the button triggers a file selection system but operating it doesn't guarantee a file upload attempt by the user; and
- emphasising upload as the action is important because successful selection of any file immediately makes the file's name and contents available to running script, unlike the olden days when it was only a state of intent to upload upon form submission.
It's already "upload" in ::-webkit-file-upload-button
so why the change to "chooser"? I appreciate the speedy response to this issue, but I think making a new name instead of using the existing convention is a mistake.
The only consideration of upload in the IRC log was
smfr: I don't like upload in the name. It's choose a file.
This is not really true because the act of choosing a file is equivalent to uploading it. Choosing a file causes (a copy of) it to move "up" from the context of the OS to that of the web page/app.
A file input only selects a file, submitting the form uploads it. They are not equivalent.
That said, I'm not thrilled with the name myself. But it's still subject to change. We had to pick something in the meanwhile.
A file input only selects a file, submitting the form uploads it. They are not equivalent
@plinss This is barely technically correct. A vanilla form won't submit the data until the user chooses, but they are the minority. Once chosen, a file is no longer private to the user. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file As soon as a file is selected, the change
event fires on the element, and the file data + name is exposed via the input.files
property. It is very common for upload controls to act on that event and immediately submit the file data to a remote machine with no further user interaction.
In your example, it's still JS that's uploading the file, not the input control. It's also entirely possible that client-side JS acts on the file without ever uploading it, see the second half of the sentence you quoted from MDN.
I also find it interesting that when describing the action you used the terms "chosen" and "selected".
An "upload control" as you describe it, is simply a file select control with script to do the upload. Without the script, or a form submission by other means, there is no upload. Whether or not this is the most common use, it's still not descriptive of what the input control does. As I said, I'm not a fan of the current name, but I'm strongly opposed to calling any part of a file input an "upload" control, this would be a disservice to authors.
Were I writing standards docs, I would use the word "select" over "choose", because that's what countless other docs already do.
Referring to it as an "upload control" is not my nomencalture, it's the spec and is independent from associated script.
I'm strongly opposed to calling any part of a file input an "upload" control, this would be a disservice to authors.
…who are already referring to it as an upload control and will continue to in the future, not least because of ::-webkit-file-upload-button
. I agree that selection better represents the initial action triggered by the button, but upload better represents the consequence of using it.
I don't think "upload" is the only answer, more that "choose" should not be. I've only bothered writing anything about this because it seemed that existing conventions were being ignored.
I'll stop bike-shedding now.
I will note that there are a lot more search results for "file picker" than "file chooser". And also most of the ones for "file chooser" in quotes seem to be about some Java thing...
There are other precedents for "file chooser", fwiw: https://developer.gnome.org/gtk3/stable/GtkFileChooserButton.html
Among other form elements, there are more pseudo-elements with prefixes, should we also standardize them? e.g.
<input type="range">
::-webkit-slider-runnable-track
::-webkit-slider-thumb
::-moz-range-thumb
::-moz-range-track
We discussed this on the Open UI telecon today following some research across component libs and resolved on file-selector-button
https://github.com/WICG/open-ui/issues/91#issuecomment-639160328
The minutes can be seen here: https://github.com/WICG/open-ui/blob/master/meetings/telecon/2020-06-04.md
Among other form elements, there are more pseudo-elements with prefixes, should we also standardize them? e.g.
<input type="range"> ::-webkit-slider-runnable-track ::-webkit-slider-thumb ::-moz-range-thumb ::-moz-range-track
+1 from me, for what is worth, but probably different issue.
+1 from me, for what is worth, but probably different issue.
Yeah there many parts that need to be made interoperable as well as exposing parts that exist across platforms but aren't. @yisibl if you have interest in aiding in that I'd love to have you start defining an anatomy for these over in Open UI which will help identify the parts across OSes, libs, and UAs including the ones you mentioned. Additionally, there may be states and other aspects we should possibly create/expose in addition.
agenda+ to see if the name proposed above makes sense to the WG.
The CSS Working Group just discussed Pseudo-selector for File Inputs
, and agreed to the following:
RESOLVED: Rename to ::file-selector-button
Why not align with HTML rather than OpenUI, Java, Gnome, etc?
So: ::file-input-button
. It's easier this way to set a precedent for ::range-input-track
, ::search-input-clear-button
, etc. I think it'd be nice to have some kind of re-usable naming scheme for the future.
In the past there have been multiple buttons in <input type=file>
, so ::file-input-button
may not be a great choice.
The CSS Working Group just discussed
Pseudo-selector for File Inputs
, and agreed to the following:* `RESOLVED: Rename to ::file-selector-button`
Is there a reason the actual spec change for that has not been made yet? Is there an open PR for it?
https://github.com/w3c/csswg-drafts/pull/5788 is the spec PR.
https://github.com/web-platform-tests/wpt/pull/26876 un-tentatives the tests.
As per this Mozilla bug, there are already vendor-specific selectors to style buttons rendered within
<input type=file>
controls for Webkit and Trident engines. Webkit alone represents the majority market share, EdgeHTML is now "legacy", leaving Gecko/Quantum as the only current major engine without it. Mozilla is reluctant to add their own vendor-prefixed selector when the sensible choice would be to make::file-upload-button
official.