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

[EuiComboBox] autoFocus behavior #4772

Merged
merged 4 commits into from
Apr 30, 2021

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented Apr 30, 2021

Summary

Adds a top-level autoFocus prop that gets passed through to the input, enabling native HTML autofocus behavior.

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

@kibanamachine
Copy link

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

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.

LGTM. Tested the temporary example (in Chrome only). Have you also tested this behavior in portal content like popover or flyout?

CHANGELOG.md Outdated Show resolved Hide resolved
src/components/combo_box/combo_box.test.tsx Outdated Show resolved Hide resolved
src/components/combo_box/combo_box.tsx Outdated Show resolved Hide resolved
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@thompsongl
Copy link
Contributor Author

Have you also tested this behavior in portal content like popover or flyout?

I haven't but I will. Popovers, portals, etc. have their own initial focus methods that are more heavy-handed and will likely take precedence.

@kibanamachine
Copy link

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

@thompsongl
Copy link
Contributor Author

thompsongl commented Apr 30, 2021

Popovers, portals, etc. have their own initial focus methods that are more heavy-handed and will likely take precedence.

I was incorrect. autoFocus works in modals and flyouts, and takes precedence over those initial focus methods. This is true for any component or DOM element that supports autoFocus (basically all EUI form controls, now including EuiComboBox).

@cchaos
Copy link
Contributor

cchaos commented Apr 30, 2021

I think that makes the most sense?

@thompsongl
Copy link
Contributor Author

I think that makes the most sense?

I agree. Use/mimic the native browser API as much as possible.

@thompsongl thompsongl merged commit 658e5d2 into elastic:master Apr 30, 2021
cchaos added a commit that referenced this pull request May 4, 2021
* add autoFocus

* revert me

* CL

* Apply suggestions from code review

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
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