-
Notifications
You must be signed in to change notification settings - Fork 1k
Debounce the invocation of the open method - fixes #1138 #1140
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
Conversation
amsul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just some minor things to address 👍
lib/picker.js
Outdated
| event.preventDefault() | ||
| P.open() | ||
| }) | ||
| }, 300)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
300 seems rather long..if it's a race condition introduced in Chrome 73, I can't imagine it would need that long 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a comment here as to why it's debounced (with a reference to the issue).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, which value would you recommend? 100ms or lower?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assume that since it's a race condition at the browser level, we wouldn't need anything more than a few milliseconds. To be safe, I think just 50ms should be sufficient. At 100ms, it starts to impact the experience minutely.
|
I have applied the proposed changes. When we are ready to merge I will squash the commits into one. |
|
@DanielRuf I think we're ready to merge em in. We can ship a new build for 3.6.1 after. |
|
I'll do the change to 50 instead of 100 ms and then squash the commits |
4899c87 to
9282a80
Compare
|
Ready to be merged. Thanks for the feedback. |
|
Hi, we've just hit this on our site. Using the most recent version of pickadate we're seeing that the close event is being fired immediately after opening ~50% of the time. If you want to replicate it consistently you need to do a long click on the input box (which explains why it happens 50% of the time). When the click is fired it is using the input box as the target element and totally ignoring the new element that has appeared. You can see this behaviour on the demo site: https://amsul.ca/pickadate.js/ This behaviour only started in Chrome 73 and is not present in Safari 12.0.3. The dirty fix that springs to mind is to have the open handler register whether the opening click has completed or not. If the click has not been completed then the close handler should do a no-op. Edit: further debugging has shown that on a slow click the focus event is fired followed by a click event on mouse up. On a normal click just the click event is fired once and so gets handled correctly. |
|
Hi @colinhowe, please read the PR and the comments and see the changes. This is a regression in Chrome. This PR is just a workaround to fix it. |
Because webKit !== Chromium ;-) |
|
I realise that about Safari. It was more to give additional context. Anyway, I've tracked down what has happened in Chromium. I'll raise a PR as I believe the issue we're seeing is different to this one. |
|
No, it is the exact same issue which is fixed by this PR. |
|
Please try the patch / changes of this PR. |
|
I am using
Expected behaviour: calendar stays open |
No one does this. You have to increase the timeout to dethrottle it. The cause is still the same. |
|
The website uses 3.6.2 - I did check before sending you the instructions. The instructions are purposefully exaggerated. All you have to do is be slow enough between mousedown and mouseup to trigger a DOM change. I figured saying 'click for ~50ms' would be less helpful. As a general fyi, older people do use the internet. They do click slowly. |
|
FYI - I just had a client let me know that on some slower machines, 100ms doesn't seem to be enough to do the trick. |
|
@gregblass we are aware of it and there is an open issue which tries a different workaround. |
|
Got it! Hey would you mind linking me to that? |
|
See #1145 |
You are rigth, but I think this will fix the whole problem: |
No description provided.