Skip to content

Html form method=dialog functionality stops working when a formsModule is loaded. #47150

Closed

Description

@SanderElias

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

When a formsModule is loaded, the folowing code no longer conforms to the W3C specs.

<dialog #dlg (close)="handleClose($event)">
  <form method="dialog" name="myForm">
      <label>
        <span>Last:</span>
        <input type="text" name="name.last" />
      </label>
      <button value="reset">Cancel</button>
      <button value="submit">Confirm</button>
   </form>
</dialog>

Clicking the submit button should close the dialog and raise an event. You can see this working in the attached StackBlitz.
The App-component works, while the forms-component doesn't fire the event.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-ivy-anbk9o?file=src%2Fapp%2Fforms%2Fforms.component.html,src%2Fmain.ts,src%2Fstyles.css,package.json,src%2Fapp%2Fforms%2Fforms.component.ts,src%2Fapp%2Ftop.component.ts,src%2Fapp%2Fapp.component.html

Please provide the exception or error you saw

The dialog doesn't close, and the corresponding event is not fired.

Please provide the environment you discovered this bug in (run ng version)

All angular versions. In the StackBlitz is version 14.1.2

Anything else?

cc @twerske You asked me to tag you here

Activity

  1. changed the title [-]Html `form method=dialog` is functionality stops working when a formsModule is loaded.[/-] [+]Html `form method=dialog` functionality stops working when a formsModule is loaded.[/+] on Aug 13, 2022
  2. added this to the needsTriage milestone on Aug 15, 2022
  3. self-assigned this
    on Aug 31, 2022
  4. kbrilla commented on Aug 31, 2022

    @kbrilla
    Contributor

    @crisbeto - after Your PR - imagine we have validation and we want to test that validation on submit, in case of form is invalid show a toast but stop closing the dialog. Now button type="submit" will only trigger ngSubmit, and leave the dialog open, but after PR to prevent autoclosing we will only need to call event.preventDefault() and it should stop dialog auto closing right?

  5. crisbeto commented on Aug 31, 2022

    @crisbeto
    Member

    Yeah, you still have access to the submit event in the ngSubmit handler so you can call preventDefault yourself.

  6. added a commit that references this issue on Sep 9, 2022
    80c66a1
  7. added a commit that references this issue on Sep 18, 2022
    0d9e767
  8. angular-automatic-lock-bot commented on Oct 10, 2022

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

  9. locked and limited conversation to collaborators on Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions