Skip to content

[EuiSelectable] Add a mixed state to EuiSelectableListItem that renders a new icon and SR-only text#6774

Merged
1Copenut merged 22 commits intoelastic:mainfrom
1Copenut:feature/euiSelectableListItem-mixed-option
May 18, 2023
Merged

[EuiSelectable] Add a mixed state to EuiSelectableListItem that renders a new icon and SR-only text#6774
1Copenut merged 22 commits intoelastic:mainfrom
1Copenut:feature/euiSelectableListItem-mixed-option

Conversation

@1Copenut
Copy link
Copy Markdown
Contributor

@1Copenut 1Copenut commented May 12, 2023

Summary

EUI team was requested to add a "mixed" state to the EuiSelectable component so teams could communicate a "selected for some" status for the options object passed into the component. This mixed state is not selectable by users, but can be updated to checked, excluded, or unchecked entirely.

I left three granular commits in the history instead of squashing, so reviewers can follow along (if so inclined) to see how I arrived at this solution. I took a long look at the MDN guidance for aria-checked to inform the screen reader text.

This PR closes #6771.


Screen Shot 2023-05-15 at 1 21 28 PM

QA

Remove or strikethrough items that do not apply to your PR.

General checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs (using @default if default values are missing) and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

@1Copenut 1Copenut requested review from cee-chen and ryankeairns May 12, 2023 18:14
@1Copenut
Copy link
Copy Markdown
Contributor Author

I need to add the documentation updates and finish testing across browsers. Will do that before EOD today and hopefully move this out of draft.

@1Copenut
Copy link
Copy Markdown
Contributor Author

jenkins test this

@1Copenut 1Copenut marked this pull request as ready for review May 15, 2023 18:27
Copy link
Copy Markdown
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

minor copy suggestions

1Copenut and others added 3 commits May 16, 2023 08:40
Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
@1Copenut 1Copenut requested a review from cee-chen May 16, 2023 21:28
@1Copenut 1Copenut added the breaking change PRs with breaking changes. (Don't delete - used for automation) label May 16, 2023
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_6774/

Copy link
Copy Markdown
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

LGTM
Small suggestion - we could add a button to reset the example. Its just as easy to reload the page, but might be nice as a reader clicks on items, checking states, and trying to understand the point... as I just did :)

Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_6774/

Comment on lines +170 to +173
<EuiI18n
token="euiSelectableListItem.includedOption"
default="Checked option."
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
<EuiI18n
token="euiSelectableListItem.includedOption"
default="Checked option."
/>
<EuiI18n
token="euiSelectableListItem.checkedOption"
default="Checked option."
/>

Since we're making the string the exact same as line 224 down below we should just go ahead and make these the same i18n token/string. Our i18n translators skip having to re-translate the same string that way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, we're repeating a bunch of i18n strings across the board down below. I'd prefer to dry those out into const's I think... any objections if I push up a clean up?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I refactored this in 7ee93d4 and found several bugs/missing or confusing SR text that was fixed as a result of cleaning up the branches (namely, mixed and non allowExclusions options did not have the correct SR text).

I think this should be fixed now - @1Copenut, do you want to do a final pass on all EuiSelectable

The permutations that generate different screen reader text that need to be tested:

cee-chen added 7 commits May 17, 2023 13:12
+ `aria-disabled` and `aria-checked` is valid - do not return undefined if disabled

+ `aria-checked` mixed is invalid for certain roles - return false if so
- add describe block tests for `role` and `aria-checked`
- add describe blocks for `checked`
- switch to RTL render
- DRY out repeated i18n tokens/strings

- Make branching easier to follow (hopefully...)

- Fix some incorrect branching logic leading to missing SR text (namely non-exclusion mixed)

- Improve SR reading by using a period instead of a hyphen (at least for FF+VO)

- Add more unit tests to snapshot branching output

+ rename various vars to be slightly clearer
- Remove `allowExclusions` from example - while they work together, it's unlikely consumers will use both, and we should focus on just mixed options for this demo to isolate concerns

- Document when consumers would want to use this state

- Add button that allows resetting mixed state display

- Fix snippet
Copy link
Copy Markdown
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

This LGTM at this point from a code & docs POV, but the screen reader text may need more robust testing. Feel free to tweak the branching if you find any issues with it!

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_6774/

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_6774/

@1Copenut
Copy link
Copy Markdown
Contributor Author

I passed through the recommended states using four screen reader combinations:

  • Safari + VO (MacOS)
  • Firefox + VO (MacOS)
  • Chrome + NVDA (Win10)
  • Firefox + NVDA (Win10)

All performed as expected with no regression that I could tell from previously coded version. Moving this to close after merging.

@1Copenut 1Copenut merged commit f8bc384 into elastic:main May 18, 2023
@1Copenut 1Copenut deleted the feature/euiSelectableListItem-mixed-option branch May 18, 2023 20:40
cee-chen added a commit to elastic/kibana that referenced this pull request May 31, 2023
## Summary

`@elastic/eui@80.0.0` ⏩ `@elastic/eui@81.0.0`

---

## [`81.0.0`](https://github.com/elastic/eui/tree/v81.0.0)

- Added ability to set `options.checked` to "mixed" in `EuiSelectable`
([#6774](elastic/eui#6774))

**Bug fixes**

- Portalled components (e.g. `EuiPopover`, `EuiModal`, `EuiFlyout`) will
correctly inherit text color from its nearest `EuiThemeProvider` parent.
`<EuiText color="default">` is no longer needed.
([#6775](elastic/eui#6775))

**Breaking changes**

- `EuiSelectable` no longer renders a `data-test-selected` attribute on
its list items. Use the `aria-checked` property instead
([#6774](elastic/eui#6774))
- Nested `EuiThemeProvider`s now render a wrapping `<span>` element in
order to correctly set the inherited text `color` of all descendants.
`<EuiText color="default">` is no longer needed.
([#6775](elastic/eui#6775))

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Constance Chen <constance.chen@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change PRs with breaking changes. (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EuiSelectable] Add a mixed state to EuiSelectableListItem that renders a minus icon and screen reader message

4 participants