-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Problem with two datepickers for date range on Safari #1077
Comments
Hi I am facing the same issue here with Safari |
What I am seeing is: if I have one open and...
In both cases, (all within In Chrome and Firefox, |
Looks like Safari is event drunk. vs from: https://www.quirksmode.org/dom/events/tests/blurfocus.html Basically, if you click within the content of the text input with another input element focused, you get something like: blur on textarea focus on text blur on text focus on textarea blur on textarea focus on text This would explain the observed behaviour. I suppose an approach to fix this might be to debounce the focus/blur events, reacting only to the last one... but... yikes. |
Interesting: facebook/react#10871 Related? |
At issue are the spurious events that safari seems to emit like crazy. In thinking about this issue, I found this workaround. As a proof of concept, I created this fiddle to demonstrate the problem and the workaround (see capture from safari below). So, I think I'm on to a workaround here and would totally welcome feedback before plodding any further ahead ;) |
This gist provides a WIP workaround for the issue in Safari. Supplying it to DatePicker as a custom input seems to resolve the issue: https://gist.github.com/pmacmillan/5e78836821ac22031567382dadd4a72e But I'm not terribly happy with it and I don't think it belongs in this library (i.e. it feels like should be fixed either as part of React or as part of an environment compat polyfill). |
The same problem here triggers a crash in Safari iOS however whatever is underlying cause seems to be different. Having stolen @pmacmillan's code, I have a test case that breaks in MacOS Safari only. Need to investigate more to find out what's causing issues in Safari. |
I've put together a fix (in part borrowing @pmacmillan's work) though I'm unsure if it should live inside React or as a separate library. Assuming the latter, it's now available for implementation: https://github.com/cliener/input-fixer |
My fork is done https://github.com/cliener/react-datepicker I've fixed the immediate problem of the endless event loop however we're now left with the the originally opened calendar sometimes stays open. Removing I've made some attempt at resolving this bug but don't haven't yet found a solution. I'm open to suggestions/contributions on this. It seems a similar endless loop in iOS has also been fixed with the changes I've made. I'll test this shortly. Any thoughts about whether I should create a PR at this point? |
PR as above. The code is now in a better state having at least fixed the endless loop. iOS Safari is entirely happy now from my tests. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
On Safari when you select a date on one of the datepickers and change to the other datepicker too quickly, both open the calendar and the focus on the input fields keeps switching.
The text was updated successfully, but these errors were encountered: