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

Dialog close() from <input> event no longer works. #4287

Closed
arlowhite opened this issue Apr 26, 2017 · 3 comments · Fixed by #4329
Closed

Dialog close() from <input> event no longer works. #4287

arlowhite opened this issue Apr 26, 2017 · 3 comments · Fixed by #4329
Assignees

Comments

@arlowhite
Copy link

Bug:

I have a dialog with an Input. When the user presses ENTER, the dialog closes.

My project is using builds from github.com/angular/material2-builds.git
This was working about 2 weeks ago, but when I last updated it broke.
So commit somewhere between April 17-April 25 caused this problem.

Now, pressing ENTER will briefly close and re-open the dialog over and over.
However, a button (click) can close using the API just fine.
See: http://plnkr.co/edit/K1TfpHfdPORKb7afApsZ?p=preview

I'm guessing one of these commits caused the issue?
85bc3a6
7428c49
29968b8

What is the expected behavior?

Should be able to call .close() in a (onKeyDown) handler.

What is the current behavior?

Dialog closes and then re-opens instead of staying closed.

What are the steps to reproduce?

http://plnkr.co/edit/K1TfpHfdPORKb7afApsZ?p=preview

What is the use-case or motivation for changing an existing behavior?

Users expect simple dialogs to close when they press enter on an Input.

Which versions of Angular, Material, OS, browsers are affected?

Latest master. 607f5a645f31e0db437b0df1192f58e14562f126

@willshowell
Copy link
Contributor

I did a little bisect of the material2-builds to help narrow it down, and it looks like there were two regressions with using keydown to close the dialog:

Regression 1

  • Commit a7f58b8 works perfectly
  • The following commit 8e6fdfc works fine if you just tap ENTER, but opens hundreds of dialogs if you hold it down

This slight regression can be attributed to #3774

Regression 2

  • Commit 58fe99c works fine if you just tap ENTER, but opens hundreds of dialogs if you hold it down
  • The following commit 667bb4e always just reopens the dialog (like your issue states)

The only MdDialog commit between this merge range is #3892 and is probably your culprit

// cc @crisbeto

@crisbeto crisbeto self-assigned this Apr 26, 2017
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 29, 2017
Fixes the dialog restoring focus before the close animation is done.

Fixes angular#4287.
@crisbeto
Copy link
Member

crisbeto commented Apr 29, 2017

It's because Material restores focus immediately, instead of waiting for the animation to finish. I've opened a PR that should fix it (#4329). Meanwhile you can work around it either by closing on keyup or disabling the open button while there's an open dialog.

andrewseguin pushed a commit that referenced this issue May 2, 2017
Fixes the dialog restoring focus before the close animation is done.

Fixes #4287.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants