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

GrafanaUI: Add indeterminate state to Checkbox #67312

Merged
merged 8 commits into from Apr 27, 2023

Conversation

JoaoSilvaGrafana
Copy link
Contributor

What is this feature?

Adds an indeterminate state to checkboxes. It picks up from this PR #65463 and adds some more styling to it, including disabled.
Screenshot 2023-04-26 at 18 08 39

Why do we need this feature?

Indeterminate is a visual only state typically used to show that 'sub options' are in a mixed state. Setting indeterminate={true} on a checkbox does not affect the value of the checkbox, but only the visual appearance.

Who is this feature for?

Everyone

Which issue(s) does this PR fix?:

Fixes #63335

Special notes for your reviewer:

Regarding a question on if we need to set indeterminate property to the checkbox via JS, I don't believe we need it, at least from a a11y perspective all that is required is that we set aria-checked='mixed'.

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@JoaoSilvaGrafana JoaoSilvaGrafana added add to changelog area/grafana/ui Issues that belong to components in the @grafana/ui library no-backport Skip backport of PR saga design system Issues related to the work of the Saga Design System labels Apr 26, 2023
@JoaoSilvaGrafana JoaoSilvaGrafana added this to the 10.0.x milestone Apr 26, 2023
@JoaoSilvaGrafana JoaoSilvaGrafana requested review from a team as code owners April 26, 2023 17:10
@JoaoSilvaGrafana JoaoSilvaGrafana requested review from jackw and eledobleefe and removed request for a team April 26, 2023 17:10
Copy link
Contributor

@joshhunt joshhunt left a comment

Choose a reason for hiding this comment

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

👏🏻

- [ ] B-series
- [ ] C-series

The indeterminate state of the checkbox should be used when there is a group of child checkboxes that are in a mix of checked and unchecked states. For instance when you have a list of checkboxes representing the columns of a table, and you want to allow the user to select which columns to display. If some of the columns are checked, and some are unchecked, then the parent checkbox should be in an indeterminate state. If all the columns are checked, then the parent should be checked. If none of the columns are checked, then the parent should be unchecked.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would mention here that <Checkbox checked indeterminate /> is discouraged as a checkboxs emit boolean values which can only ever be TRUE or FALSE, and if something is partially true, then it is false.

@eledobleefe
Copy link
Contributor

Hi! I run this branch in my local and I found the indeterminate state shown like this. Is it right?

Captura de pantalla 2023-04-27 a las 12 09 26

Captura de pantalla 2023-04-27 a las 12 08 59

right: 3px;
top: calc(50% - 1.5px);
height: 3px;
border: solid ${theme.colors.primary.contrastText};
Copy link
Contributor

Choose a reason for hiding this comment

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

@JoaoSilvaGrafana If I get rid of this border the indeterminate state looks good, otherwise, it looks like the screenshots I added to my comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Firefox! :shakes-fist:
Thanks for checking Laura 😄 I will see how to solve this, that line is there solving another edge case problem...

Copy link
Contributor

Choose a reason for hiding this comment

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

Happy to help! 😄

Copy link
Contributor

@eledobleefe eledobleefe left a comment

Choose a reason for hiding this comment

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

You fixed it! 😄 LGTM 🎉

Captura de pantalla 2023-04-27 a las 13 36 52

@JoaoSilvaGrafana JoaoSilvaGrafana merged commit 48933e1 into main Apr 27, 2023
14 checks passed
@JoaoSilvaGrafana JoaoSilvaGrafana deleted the joao_silva/indeterminate-checkbox branch April 27, 2023 13:18
@zerok zerok removed this from the 10.0.x milestone May 2, 2023
@zerok zerok added this to the 10.0.0 milestone May 2, 2023
@zerok zerok modified the milestones: 10.0.0, 10.0.0-preview May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend area/grafana/ui Issues that belong to components in the @grafana/ui library no-backport Skip backport of PR saga design system Issues related to the work of the Saga Design System
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkbox: Add proper indeterminate state to checkbox component
5 participants