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

onFocus is fired twice #665

Closed
ericgio opened this issue Aug 24, 2021 · 2 comments
Closed

onFocus is fired twice #665

ericgio opened this issue Aug 24, 2021 · 2 comments
Labels

Comments

@ericgio
Copy link
Owner

ericgio commented Aug 24, 2021

Version

5.2

Steps to reproduce

https://codesandbox.io/s/blue-dawn-z4l1l?file=/src/index.js

Expected Behavior

onFocus should only fire once

Actual Behavior

onFocus fires twice, once for the focus event and once for the click event.

Happening because onFocus is being called inside onClick here.

@ericgio ericgio added the bug label Aug 24, 2021
@ericgio
Copy link
Owner Author

ericgio commented Sep 5, 2021

Workaround:

<Typeahead
  ...
  onFocus={(e) => {
    if (e.type === 'focus') {
      // Do what you want on focus
    }
  }}
/>

ericgio added a commit that referenced this issue Oct 17, 2021
@ericgio
Copy link
Owner Author

ericgio commented Oct 18, 2021

Fixed in v6.0.0-alpha.2

@ericgio ericgio closed this as completed Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant