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

Focus event triggered on fast interaction #2181

Open
albanx opened this issue Feb 9, 2022 · 5 comments
Open

Focus event triggered on fast interaction #2181

albanx opened this issue Feb 9, 2022 · 5 comments

Comments

@albanx
Copy link

albanx commented Feb 9, 2022

this.inputRef.focus();

On Firefox on Mac OS, if you keep clicking fast enough between the dates of a calendar it will trigger the focus event and therefore the clickOutSide function by the related target, causing the datepicker to close.

This issue happens on Firefox and unit test with jest and react testing library. Cannot replicate on chrome.

By commenting the above line everything works fine including the test.

@ljharb
Copy link
Member

ljharb commented Feb 9, 2022

When that line is commented, then the isFocused prop wouldn't work, no?

@ljharb
Copy link
Member

ljharb commented Feb 9, 2022

The blame points to 9e6e89b / #212.

@albanx
Copy link
Author

albanx commented Feb 9, 2022

When that line is commented the date picker works fine.
when is uncommeted this happens:

  • Click dates fast enough in Firefox
  • At some point, the element looses focus,
  • the focus goes to the text INPUT that gets the date,
  • the text INPUT triggers the focus and
  • the focus triggers the outSideClick function with relatedTarget the INPUT that is outside the datepicker
  • the date picker then detects it as outside click and closes itself

See attached video
https://user-images.githubusercontent.com/1130664/153264673-ca1231e0-8fb1-462f-bd39-d4c252ff74db.mov

@ljharb
Copy link
Member

ljharb commented Feb 9, 2022

I understand when your problem occurs; i'm concerned that removing that line will re-cause the breakage that adding that line fixed.

@albanx
Copy link
Author

albanx commented Feb 9, 2022

The root cause is the fact that the element is getting focus when it should not. I still cannot explain why clicking fast or on dates causes the top input to get focus

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

No branches or pull requests

2 participants