Skip to content

Submitting a form in a dialog with Enter, reopens the dialog #2555

@Hzunax

Description

@Hzunax

Expected behavior

Submitting a form by pressing "Enter" on keyboard, while a form element is in focus, triggers a submit event on the form. If the submit handler also closes the dialog,

Actual Behavior

A submit handler is added on the form, which closes the dialog the form is in.
When pressing "Enter" on keyboard, while a form element is in focus, the form will be submitted, close the dialog, but then reopen the dialog.

It seems submit is triggered on key-down, then focus is back on the invoker and on key-up, it invokes the dialog again.

Reproduction steps

https://stackblitz.com/~/github.com/Hzunax/lion-demo

Switch to branch issue-dialog-form-submit

  1. Open dialog
  2. Set focus on the input
  3. Press "Enter" on keyboard
  4. You will see the dialog invoked again

Metadata

Metadata

Assignees

No one assigned

    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