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

[EuiSuggest] Use EuiSelectable #5157

Merged
merged 105 commits into from
Feb 9, 2022
Merged

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented Sep 8, 2021

Summary

Resolves #3733 by converting the list element in EuiSuggest to use EuiSelectable, which now implements the ARIA 1.2 combobox pattern.

Other changes:

  • Completes keyboard remediation ([EuiSuggest] Accessibility #2404)
    • EuiSelectable does the heavy lifting
    • Filtering and Enter selection behavior is left to consumers, so it intentionally appears incomplete
  • ⚠️ Breaking changes
    • Removes EuiSuggestInput
    • Requires either aria-label or aria-labelledby
    • Renames sendValue prop to onSearchChange

Closes #5336, closes #2404, closes #4419, closes #4345, closes #4342

Checklist

  • Check against all themes for compatibility in both light and dark modes

- [ ] Checked in mobile

  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

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

@thompsongl
Copy link
Contributor Author

I had an idea for a custom hook that would provide stateful logic and ARIA attributes needed to make combox-like components that we could use here and elsewhere. Going to look into that before determining the best path forward for this PR.

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@thompsongl
Copy link
Contributor Author

@1Copenut Before I open this up for full review, would you mind checking this for a11y completeness? I'd like to have that part solid before making further review adjustments.

@kibanamachine
Copy link

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

@thompsongl
Copy link
Contributor Author

thompsongl commented Feb 7, 2022

I noticed the focus was being returned to the search input and the listbox being re-opened when I tried to tab away

Looks like a focus trap change in #5584 had an impact here. Still trying to diagnose.

Update:
Should be fixed in a58f492.
Haven't tracked it down, but I suspect a bug was fixed in a dep and made available to us in #5584. The now-current configuration seems more correct to me based on desired key behavior.

@kibanamachine
Copy link

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

@cee-chen
Copy link
Member

cee-chen commented Feb 8, 2022

🎉 This keyboard accessibility is way better than prod! Couple QA comments/questions in no particular order (apologies if I should have threaded these):

  1. Is there any way to override (via CSS) the white gradient/mask on the .euiSelectableList__list dropdown for EuiSuggest only? It just looks weird on EuiSuggest (personal opinion).

  2. It looks like this longer item is getting cut off and cannot be scrolled to in the virtualized dropdown demo. It does not get cut off when the demo is not virtualized. Any thoughts on how to fix it? Screen Shot 2022-02-08 at 9 48 59 AM

  3. [optional, can be a separate PR] This is not a specific issue with EuiSuggest, but with the underlying EuiSelectable - when on the virtualized scrolling dropdown example, when I press a non-character key (e.g. shift, ctrl, option, command), I get unexpectedly punted/scrolled back up to the top item in the list. I feel like we should fix this by checking for keydowns that aren't actual input characters. Thoughts?

  4. [optional, question] Maybe I'm just dumb/missing how EuiSuggest works, but is there any way to validate that pressing enter or space on an option actually selects something? The input value never appears to change. 🙈

@thompsongl
Copy link
Contributor Author

thompsongl commented Feb 8, 2022

Is there any way to override (via CSS) the white gradient/mask on the .euiSelectableList__list dropdown for EuiSuggest only? It just looks weird on EuiSuggest (personal opinion).

Maybe these could be removed in non-virtualized instances? Perhaps @cchaos has thoughts.

It looks like this longer item is getting cut off and cannot be scrolled to in the virtualized dropdown demo. It does not get cut off when the demo is not virtualized. Any thoughts on how to fix it?

This is a noted limitation of virtualized EuiSelectable lists (see Row height and virtualization). We could add a link to this from the EuiSuggest page.

[optional, can be a separate PR] This is not a specific issue with EuiSuggest, but with the underlying EuiSelectable - when on the virtualized scrolling dropdown example, when I press a non-character key (e.g. shift, ctrl, option, command), I get unexpectedly punted/scrolled back up to the top item in the list. I feel like we should fix this by checking for keydowns that aren't actual input characters. Thoughts?

Yep, separate PR makes sense. In that same PR I can resolve @1Copenut concern about the input clear button not responding to ENTER. Both of these are EuiSelectable issues and not specific to EuiSuggest.

[optional, question] Maybe I'm just dumb/missing how EuiSuggest works, but is there any way to validate that pressing enter or space on an option actually selects something? The input value never appears to change.

You could console.log (or whatever) the onChange callback. We leave selection behavior up to the consumer. I'll add to the docs that selection is not handled with internal state.

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

👍 I retested for keyboard and screen reader behavior with VO + Safari on MacOS Big Sur. The focus handling is spot on and the reduced set of options when I started typing worked well too. VO tends to be fairly verbose and repetitive, so I have no doubt this will be a big upgrade for NVDA and JAWS too. Thanks @thompsongl !

Copy link
Member

@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.

Mostly minor/optional comments, and a few maybe-blocking comments about unit tests

src/components/suggest/_suggest_item.scss Show resolved Hide resolved
src/components/suggest/suggest.tsx Outdated Show resolved Hide resolved
src/components/suggest/types.ts Outdated Show resolved Hide resolved
src/components/suggest/types.ts Show resolved Hide resolved
src/components/suggest/suggest_item.tsx Show resolved Hide resolved
src/components/suggest/suggest.tsx Show resolved Hide resolved
src/components/suggest/suggest.tsx Show resolved Hide resolved
src/components/suggest/suggest.tsx Outdated Show resolved Hide resolved
src/components/suggest/suggest.tsx Show resolved Hide resolved
@cchaos
Copy link
Contributor

cchaos commented Feb 8, 2022

Is there any way to override (via CSS) the white gradient/mask on the .euiSelectableList__list dropdown for EuiSuggest only? It just looks weird on EuiSuggest (personal opinion).

Unfortunately there's no way to discriminately show the overflow mask for when the box is scrolling or not. Yes, it may be awkward for short lists, but it has high impact on long lists to indicate "there is more below here":
Screen Shot 2022-02-08 at 14 14 18 PM

I'm open to ideas, but I don't want to turn it off for all of EuiSelectable/EuiSuggest because it will turn if off for overflowing lists.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Did a real quick final code and design review. LGTM!

@kibanamachine
Copy link

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


describe('EuiSuggest', () => {
describe('onItemClick', () => {
it('is called when an option is clicked', () => {
Copy link
Member

Choose a reason for hiding this comment

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

🤩 Nice!! These Cypress tests are great!!! Thanks for adding them!

Copy link
Member

@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.

New tests look awesome! I have just one super minor/opinionated code style suggestion, feel free to ignore it and merge if you don't think it's a significant improvement

thompsongl and others added 2 commits February 8, 2022 17:32
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
@thompsongl thompsongl enabled auto-merge (squash) February 9, 2022 00:03
@kibanamachine
Copy link

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

@thompsongl thompsongl merged commit c8f2b55 into elastic:main Feb 9, 2022
1Copenut pushed a commit to 1Copenut/eui that referenced this pull request Feb 9, 2022
* update euiselectable with paddingSize prop, tests

* euisuggest use euiselectable; more tests

* CL

* handle empty list

* WIP: useCombobox

* WIP: temporary docs

* snapshots

* keyboard nav

* i18n

* prevent prop overlap

* open logic

* status i18n

* clean up

* aria-checked; empty state

* restrict aria-checked to role=option items

* checked screenreader text

* WIP: EuiScreenReaderStatus

* i18n token

* i18n fix

* filter out disabled items

* space bar toggles selection in non-searchable euiselectable

* update tri-state helper text

* fix dupe token

* euiScreenReaderStatus

* optional virtualized rendering, use in EuiSelectable

* fix CL

* expose isVirtualized option

* CL

* Fixed tall lists by added `maxHeight` prop

* Fix a few item styles

* Fix height for `isVirtualized` and add `title`s to spans

* [EuiSelectable] Don’t render unnecessary wrappers

* More cleanup of item code and styles

Deprecates `descriptionDisplay` and `labelDisplay`

* Fixing `fullWidth` support

* Docs

* import

* 1.2 spec

* pass aria attrs to input

* clean up

* fix CL

* add key to non-virtualized list items

* remove unused component; rename sendValue prop

* Refactor to simplify EuiScreenReaderStatus, support more panel prop configurations in EuiPopover, and rely on new panel props support in EuiSuggest

* clean up

* Fix input style when append array is empty; Update docs for suggest item

* euiscreenreaderonly

* euiscreenreaderstatus

* tests, comments

* Apply suggestions from code review

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* merge fixes

* clean up

* docs clean up

* docs clean up

* id pattern fix

* fix bad merge

* disabled redundant focus trap

* docs and tests

* move state message

* Update src/components/suggest/suggest.tsx

Co-authored-by: Constance <constancecchen@users.noreply.github.com>

* lint

Co-authored-by: cchaos <caroline.horn@elastic.co>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants