Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
koenner01 opened this issue Feb 22, 2018 · 7 comments
Assignees
Labels
Event: dmcdindia Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@koenner01
Copy link
Contributor

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

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 22, 2018
@koenner01
Copy link
Contributor Author

workaround can be to use the vanilla javascript addEventListener functionality

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Feb 28, 2018
@magento-engcom-team
Copy link
Contributor

@koenner01, thank you for your report.
We've acknowledged the issue and added to our backlog.

@amjadm61
Copy link
Member

I'm working on it at #dmcdindia

@magento-engcom-team
Copy link
Contributor

@amjadm61 thank you for joining. Please accept team invitation here and self-assign the issue.

@sidolov
Copy link
Contributor

sidolov commented May 25, 2018

Hi @koenner01. Thank you for your report.
The issue has been fixed in #15340 by @amjadm61 in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.5 release.

@sidolov
Copy link
Contributor

sidolov commented Jun 5, 2018

Hi @koenner01. Thank you for your report.
The issue has been fixed in #15696 by @vgelani in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

@sidolov
Copy link
Contributor

sidolov commented Jun 23, 2018

Hi @koenner01. Thank you for your report.
The issue has been fixed in #16281 by @vgelani in 2.1-develop branch
Related commit(s):

The fix will be available with the upcoming 2.1.15 release.

@sidolov sidolov added the Fixed in 2.1.x The issue has been fixed in 2.1 release line label Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Event: dmcdindia Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants