Skip to content

Submitting search form (mini) with enter key fires event handlers bound by jquery twice #13793

Closed
@koenner01

Description

@koenner01

When submitting the search form in the header with the enter key on the keyboard, event handlers that were bound to the form submit (through jQuery) are fired twice.

Preconditions

  1. PHP 7.0
  2. CE 2.2 (also tested 2.1.11)

Steps to reproduce

  1. Create a javascript which adds an event handler to the form submit
$('#search_mini_form').on('submit', function(e) {
    console.log('listening for form submit');
});
  1. Submit the search form in the header with a value by pressing the enter button

Expected result

  1. Our created listener is only fired once

Actual result

  1. Listener is fired twice

In module-search/view/frontend/web/form-mini.js the _onKeyDown function is adding a trigger to the enter key

case $.ui.keyCode.ENTER:
    this.searchForm.trigger('submit');
    break;

This trigger is causing the submit event to be fired twice

Metadata

Metadata

Assignees

Labels

Event: dmcdindiaFixed in 2.1.xThe issue has been fixed in 2.1 release lineFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions