Skip to content
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

Prevent ENTER propagation on form #826

Merged
merged 2 commits into from Jan 2, 2015
Merged

Prevent ENTER propagation on form #826

merged 2 commits into from Jan 2, 2015

Conversation

fdaugan
Copy link
Contributor

@fdaugan fdaugan commented Feb 18, 2014

On "ENTER" keydown on picker, prevent the closest form to be submitted too.
Updated PR of #674

On "ENTER" keydown on picker, prevent the closest form to be submitted too.
Updated PR of #674
@eternicode eternicode added this to the 1.3.1 milestone Mar 2, 2014
@@ -1200,6 +1200,8 @@
this.fill();
if (this.picker.is(':visible')){
e.preventDefault();
e.stopPropagation && e.stopPropagation();
e.cancelBubble = true; // IE6,7,8 support
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery events' stopPropagation method does both of these (check for e.stopPropagation's existence and setting cancelBubble to true), so just a call to that would work.

https://github.com/jquery/jquery/blob/1.8-stable/speed/jquery-basis.js#L2122

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please replace the check of e.stopPropagation and the e.cancelBubble = true with a single e.stopPropagation() call

@eternicode
Copy link
Contributor

Doesn't the preventDefault call do this? It's working for me in Chrome, at least; in what browsers is it not working for you?

@fdaugan
Copy link
Contributor Author

fdaugan commented Mar 2, 2014

FF and IE7, IE8 (at least)

@acrobat acrobat modified the milestones: 1.3.2, 1.4.0 Dec 15, 2014
@acrobat
Copy link
Member

acrobat commented Jan 1, 2015

I came by this piece of info, so the combination of preventDefault + stopPropagation should fix this issue!

event.preventDefault(): Prevents the default action of the event from triggering. Does not stop the event > propagation to parent DOM elements.
event.stopPropagation(): Prevents the default action of the event from propagating to parent DOM elements.

@fabdouglas please fix the note added above and then this PR should be ready to merge :)

@acrobat
Copy link
Member

acrobat commented Jan 2, 2015

Thanks @fabdouglas!

acrobat added a commit that referenced this pull request Jan 2, 2015
Prevent ENTER propagation on form
@acrobat acrobat merged commit 4272c75 into uxsolutions:master Jan 2, 2015
@acrobat acrobat mentioned this pull request Jan 2, 2015
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants