Skip to content

Conversation

lpsinger
Copy link
Contributor

@lpsinger lpsinger commented Oct 7, 2023

Summary

Support indeterminate checkboxes through both the CSS :indeterminate selector and also the data-indeterminate attribute.

Fixes #918.

Breaking change

This is not a breaking change.

Related issue

Fixes #918.

Related pull requests

None

Preview link

We use these in https://gcn.nasa.gov/ for two-level lists of options. You would have to log in to see it, so here's a screen shot:

Screenshot 2023-10-06 at 20 10 05

Also, I've updated Storybook in this PR and you can preview it there.

Problem statement

There are times when you have a nested list of on/off options and you want to show when a top-level category has some, but not all and not none, of its children selected. In the example above, it is email notification preferences for a number of topics which are organized into categories.

Solution

The browser platform provides built-in support for indeterminate checkboxes, with the JavaScript input.indeterminate property mapped to the CSS :indeterminate selector.

However, since there is no HTML attribute to control the input.indeterminate property, I've also implemented a data-indeterminate attribute.

Major changes

This seems like a minor change.

Testing and review

Check out the branch for this PR, launch Storybook, and navigate to the Checkbox page.

@lpsinger lpsinger changed the title Add styling for indeterminate checkboxes USWDS - Checkbox: Add styling for indeterminate checkboxes Oct 8, 2023
@thisisdano thisisdano added Role: Dev Development/engineering skills needed Package: Checkbox/Radio Needs: Discussion We need to discuss an approach to this issue labels Oct 12, 2023
@thisisdano
Copy link
Contributor

Thanks for this contribution. We're going to take a look at it in the next sprint and try to determine any next steps. Stay tuned!

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there @lpsinger

Thanks for taking this on! This is looking good. Just a few ideas and suggestions for continuity.

There is also a forced-colors mode issue that needs to be addressed. Do you have experience with forced-colors or high-contrast modes?

Let us know if you have any questions!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High contrast modes

There is a discrepancy with how the checkbox is displayed in high-contrast modes. I believe it's because it is still able to receive the checked status so it's changing the background color.

Do you have any experience with high contrast / forced-colors modes? Would you be able to try to resolve this?

Kapture.2023-10-23.at.13.16.41.mp4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any experience with high contrast / forced-colors modes? Would you be able to try to resolve this?

No, I don't. Is it better if I try to do that or if a USWDS team member does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't even know how to activate these settings in my browsers (Safari, Chrome, Firefox). I can't find anything that resembles the right panel of that screen capture.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing story

Semi-related to this work, but this test template is not being imported into usa-checkbox-stories.js so it's not accessible via Storybook. We should consider importing properly or removing.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to fix that, myself, and it does sound unrelated. Perhaps that would work best as a separate PR?

@mahoneycm mahoneycm added this to the uswds 3.8.0 milestone Nov 16, 2023
@mahoneycm mahoneycm changed the base branch from develop to checkbox-indeterminate-feature-branch November 16, 2023 22:04
@mahoneycm
Copy link
Contributor

Hello again @lpsinger

We've decided we will take on the color contrast work needed to get this enhancement merged more quickly! I've updated the PR's target branch to a new feature integration branch we'll use to keep track of all related work.

Do you have the bandwidth to address the other change requests outside of the color contrast work?

Thank you again for your time and effort in this contribution! Excited to get it merged.

lpsinger and others added 2 commits November 16, 2023 18:50
Support [indeterminate checkboxes] through both the CSS
`:indeterminate` selector and also the `data-indeterminate`
attribute.

Fixes uswds#918.

[indeterminate checkboxes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes
…io-colors.scss

Co-authored-by: mahoneycm <charlie.mahoney@bixal.com>
@lpsinger lpsinger force-pushed the checkbox-indeterminate branch from aea0f7e to 611d481 Compare November 16, 2023 23:50
@lpsinger
Copy link
Contributor Author

Do you have the bandwidth to address the other change requests outside of the color contrast work?

I think that I have addressed them now.

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this, LGTM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new asset? Could we replace with remove from USA Icons?

image

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! Will update high-contrast styles and storybook patterns from feature branch

@mahoneycm mahoneycm merged commit c1bfca6 into uswds:checkbox-indeterminate-feature-branch Nov 30, 2023
@lpsinger lpsinger deleted the checkbox-indeterminate branch November 30, 2023 14:27
@mejiaj mejiaj removed this from the uswds 3.8.0 milestone Jan 8, 2024
@mejiaj
Copy link
Contributor

mejiaj commented Jan 8, 2024

Removing release milestone because original issue is already included in 3.8.0.

@mejiaj mejiaj removed Needs: Discussion We need to discuss an approach to this issue Status: Triage labels Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: Checkbox/Radio Role: Dev Development/engineering skills needed
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add indeterminate checkbox styling
5 participants