-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(datepicker): multiple dialog open if the user holds down enter key #12238
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
src/lib/datepicker/datepicker.ts
Outdated
@@ -380,6 +380,10 @@ export class MatDatepicker<D> implements OnDestroy, CanColor { | |||
|
|||
/** Open the calendar as a dialog. */ | |||
private _openAsDialog(): void { | |||
if (this._dialogRef) { |
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'm curious, why is this needed? It looks like in the open
method where this is called from we already set a variable to make sure it only gets opened once. Is that not working for some reason?
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 think that when you're holding the key down, eventually some of them go through, because we reset some of the variables in a setTimeout
. You can see in the gif how it can take a little bit of holding before the dialogs start stacking.
EDIT: I think it might also have to do with the fact that we change _opened
variable in a callback to dialogRef.afterClosed
which fires once the animation is finished.
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.
This change feels like masking the problem rather than fixing it. What if we switch to doing it in beforeClosed
instead?
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.
That one doesn't help much either. The only difference is that beforeClose
is fired when the animation starts (which is still async) and the other one fires when the animation is done. IMO doing this is fine since it's pretty low maintenance on our end and it handles an edge case.
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, as long as we've tried other solutions. Can you add a comment explaining why this is necessary even though it looks like it would be handled above?
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.
Done.
Fixes the case where the user might be holding down the enter key for a datepicker in touch mode, which could cause it to open multiple dialogs at the same time.
b5e88ae
to
ad9a032
Compare
#12238) Fixes the case where the user might be holding down the enter key for a datepicker in touch mode, which could cause it to open multiple dialogs at the same time.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes the case where the user might be holding down the enter key for a datepicker in touch mode, which could cause it to open multiple dialogs at the same time.
For reference:
