Skip to content

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

Closed

Description

@arlowhite

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

Activity

  1. willshowell commented on Apr 26, 2017

    @willshowell
    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

  2. self-assigned this
    on Apr 26, 2017
  3. added a commit that references this issue on Apr 29, 2017
    0055c76
  4. crisbeto commented on Apr 29, 2017

    @crisbeto
    Member

    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.

  5. added a commit that references this issue on May 2, 2017
    afaa2dc
  6. angular-automatic-lock-bot commented on Sep 5, 2019

    @angular-automatic-lock-bot

    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.

  7. locked and limited conversation to collaborators on Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions