Skip to content

md-autocomplete trigger submit on ENTER #3159

Closed

Description

@Knoxvillekm

md-autocomplete trigger submit form by ENTER click on option:
Plunker template: https://plnkr.co/edit/0a8lqrodE9WVTZEJprlI?p=preview

Activity

  1. sumpton commented on Feb 17, 2017

    @sumpton

    I am not sure I understand what @Knoxvillekm is after, but it likely relates to my question.

    Are there plans for something like a "change" Output in md-select, or "selectItem" I am currently using in

    https://ng-bootstrap.github.io/#/components/typeahead

  2. szykov commented on Feb 18, 2017

    @szykov

    @Knoxvillekm as workaround you can use this:
    <form action="" method="POST" (keydown.enter)="$event.preventDefault()">

    But keep in mind that it will prevent default behavior for all elements. As an example in textarea it won't trigger new line when hit enter. For avoiding it put an exception in a function like so:

     if (event.target.type !== 'textarea') {
          event.preventDefault();
     }
    
  3. frankspin89 commented on Mar 6, 2017

    @frankspin89

    This is indeed a bug in my opinion. When using enter on autocomplete field, it needs to prevent submitting the form.

  4. jefersonestevo commented on Mar 16, 2017

    @jefersonestevo
    Contributor

    I agree with @frankspin89 that the enter should not submit the form. I think that it should just select the option like the md-select does.

  5. oshri551 commented on Mar 20, 2017

    @oshri551

    I think the same thing exist in mdInput so it's probably related

  6. xuanshenbo commented on Mar 21, 2017

    @xuanshenbo

    This is definitely a bug. If ENTER does not trigger submit in a textarea, it shouldn't either for autocomplete

  7. PeS82 commented on Mar 22, 2017

    @PeS82

    @oshri551 mdInput is different beast. It should submit form when hitting Enter from regular INPUT fields. Unlike in TEXTAREA where you need Enter for paragraph.

    And unlike in combo/select and here (autocomplete) where hitting Enter should select activated option but by all means should not submit form.

    I was about to file an issue and found this one instead. +1

  8. added a commit that references this issue on Mar 22, 2017
    159a880
  9. jefersonestevo commented on Mar 22, 2017

    @jefersonestevo
    Contributor

    I've created the PR #3727 that fixes this behavior and if the material team think that it's ok we may get that fixed soon

  10. frankspin89 commented on Mar 22, 2017

    @frankspin89

    @jefersonestevo Thank you sir. Hoping that your pr is merged soon.

  11. added a commit that references this issue on Mar 29, 2017
    bedf5a1
  12. added a commit that references this issue on Apr 16, 2017
    ac476e4
  13. 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.

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

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