Skip to content

[EuiComboBox] Fix keyboard selection when sortMatchesBy=startsWith#3823

Merged
thompsongl merged 4 commits intoelastic:masterfrom
thompsongl:3812-sortMatchesBy
Jul 30, 2020
Merged

[EuiComboBox] Fix keyboard selection when sortMatchesBy=startsWith#3823
thompsongl merged 4 commits intoelastic:masterfrom
thompsongl:3812-sortMatchesBy

Conversation

@thompsongl
Copy link
Copy Markdown
Contributor

@thompsongl thompsongl commented Jul 29, 2020

Summary

Fixes #3812, in which using the keyboard to select an option in EuiComboBox when sortMatchesBy=startsWith would select the wrong option.

The problem arose from the sort logic only occurring during the render function, bypassing the state store that the keyboard logic uses to track active options.

This change moves the logic to the central getMatchingOptions function, which updates component state.

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation

  • Checked Code Sandbox works for the 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

@thompsongl thompsongl requested a review from chandlerprall July 29, 2020 22:28
@kibanamachine
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Changes LGTM! Tested with the published docs' Sorting matches example, where the bug has been reproducible. Also tested examples without startsWith to verify those still function as expected.

Thanks for adding the test case!

@kibanamachine
Copy link
Copy Markdown

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

@thompsongl thompsongl merged commit b4b99a0 into elastic:master Jul 30, 2020
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.

EuiComboBox broken keyboard navigation when using sortMatchesBy=startsWith

3 participants