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

[EuiSelectable] Handle more keyboard scenarios #5613

Merged
merged 8 commits into from
Feb 10, 2022

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented Feb 9, 2022

Summary

Following up on some keyboard-related requests in #5157:

  • Enter should work with the "clear" button
  • Alt, Shift, Cmd, and Option should not change focus of list items

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in Chrome, Safari, Edge, and Firefox
  • Added or updated jest and cypress 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_5613/

@thompsongl thompsongl marked this pull request as ready for review February 9, 2022 18:31
@kibanamachine
Copy link

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

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.

Thanks @thompsongl, code is working really well in keyboard and screen reader tests. I left some suggestions to swap Cypress synthetic events for real events in the spec file. I'm recommending we use real browser events as much as possible, but am 💯 making this a follow on PR if that's more appropriate.

.should('have.attr', 'title', 'Enceladus');
});

cy.get('[data-test-subj="clearSearchButton"]')
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about duplicating this test for Space keypress? It's not the dryest code I've ever suggested, but I can live with that for the improved Clear button checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in e2e2252

},
];

describe('EuiSelectable', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Great call adding a Cypress spec! I'd like to use cypress-real-events helpers for the click and keyboard interactions as much as possible. I'll add notes to individual lines to change, and I'm 99% sure they'll pass on first try. They worked on my machine anyhow :)

I swapped cy.type(string) for cy.realType(string) || cy.realPress(string) and the cy.click() for cy.realClick() while testing. I opted for realPress when it was a single key, and kept realType for multiple characters like "esc".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated all in e2e2252

src/components/selectable/selectable.spec.tsx Outdated Show resolved Hide resolved
src/components/selectable/selectable.spec.tsx Outdated Show resolved Hide resolved
src/components/selectable/selectable.spec.tsx Outdated Show resolved Hide resolved
src/components/selectable/selectable.spec.tsx Outdated Show resolved Hide resolved
src/components/selectable/selectable.spec.tsx Outdated Show resolved Hide resolved
src/components/selectable/selectable.spec.tsx Outdated Show resolved Hide resolved
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.

💯 LGTM!

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@thompsongl thompsongl enabled auto-merge (squash) February 10, 2022 22:09
@kibanamachine
Copy link

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

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

Successfully merging this pull request may close these issues.

3 participants