Skip to content

[selectors-4] Clarify :blank application to radio buttons etc. #3339

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

Open
fantasai opened this issue Nov 23, 2018 · 4 comments
Open

[selectors-4] Clarify :blank application to radio buttons etc. #3339

fantasai opened this issue Nov 23, 2018 · 4 comments
Labels
selectors-4 Current Work

Comments

@fantasai
Copy link
Collaborator

Andrew Fedoniouk points out that it's not entirely clear whether/how :blank applies to radio buttons etc.
https://lists.w3.org/Archives/Public/www-style/2018Nov/0028.html
We should clarify this. Some options are:

  • :blank checks the 'value' on radio buttons and checkboxes; :not(:blank) effectively always applies
    -:not(:blank) applies when a radio button or checkbox is has a non-blank 'value' and is checked (will submit if not disabled); :blank applies otherwise
  • :blank applies to each input element in a group when no radio button or checkbox in its group is checked

Probably the most simple definition is 1; it largely falls out of the existing definition. However the last definition is perhaps more useful. It would be good to hear from authors here what they expect.

@fantasai fantasai added the selectors-4 Current Work label Nov 23, 2018
@Dan503
Copy link

Dan503 commented Nov 24, 2018

The very first thing that came to mind for me was that input[type=checkbox]:blank would essentially be the same as writing input[type=checkbox]:not(:checked).

This is because if a checkbox is not checked, it visually tends to appear blank.

If input[type=checkbox]:not(:checked) does the same thing as input[type=checkbox]:blank then I don't see the point in having input[type=checkbox]:blank aside from a slightly cleaner syntax.

@Loirooriol
Copy link
Contributor

Loirooriol commented Nov 24, 2018

I like the last definition, i.e. let :blank select form controls which, supposing they had the required attribute and were mutable, would suffer from being missing. This would mean:

  • For checkboxes, :blank behaves like :not(:checked).
  • For radio buttons, :blank matches if no element in the radio button group is checked.
  • For file uploads, :blank matches if the list of selected files is empty.
  • For selects, :blank matches if no option is selected, or if the only selected option is the placeholder label option.
  • For buttons and hidden inputs, :blank never matches.
  • For other inputs and textareas, :blank matches if the value is not empty.

@fantasai
Copy link
Collaborator Author

fantasai commented Dec 7, 2018

@Loirooriol Overall I agree with you, except for checkboxes: checkboxes can also be grouped and it makes sense to treat them like radio buttons. Checkbox groups are essentially like radio button groups, except that the items are non-exclusive. You'll see surveys, for example, vary between checkboxes and radio buttons for the same format of question, except that they use checkboxes when they want to allow multiple selections.

@Loirooriol
Copy link
Contributor

@fantasai "checkboxes can also be grouped". Any reference to this? In the spec I can find the radio button group concept and the RadioNodeList interface. I can't find anything analogous for checkboxes.

Multiple checkboxes can have the same name, not sure if this is what you mean. But this also applies to text inputs, and doesn't mean they are grouped in some special way.

And I think it's natural to say that a form control suffers from being missing if it's blank and it's required (and possibly other constraints like mutability). So I would define :blank this way, and checkbox groups are not considered when determining if it suffers from being missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selectors-4 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants