Skip to main content

Search and Top Navigation

#8282 closed enhancement (fixed)

Opened April 30, 2012 12:48PM UTC

Closed April 30, 2012 03:48PM UTC

Last modified November 24, 2012 10:51PM UTC

Double escape clear IE form, continue Ticket #7643

Reported by: r2363c Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.19
Keywords: Cc:
Blocked by: Blocking:
Description

On IE, when you double press on escape key it cause a form clear.

In current usage it doesn't happen, but when you use the JQuery UI autocompletion it can happen as the escape key is used to cancel autocompletion.

Ticket #7643 raised 9 month ago was closed as it was conclude that it wasn't a JQuery UI bug, and I agree on that.

However I think it make sense to integrate a workaround in this component to avoid this side effect on IE.

I've added a comment on the closed ticket, but it seems to be ignored (quite normal on a closed ticket), That's why I open a new ticket with my previous comment.

I suggest to add a preventDefault() call on the keydown.autocomplete handle

Then I suggest to change the code (on minimized version)

case e.ESCAPE:b.element.val(b.term),b.close(c);break;

by

case e.ESCAPE:b.element.val(b.term),b.close(c);c.preventDefault();break;

I've tested it on IE6&8 and FF11 and chrome15 and it seems to fix the point on IE and to do not cause any trouble on others.

On the last source code (I haven't tested it) it should be

case keyCode.ESCAPE:
  if ( self.menu.element.is(":visible") ) {
	self._value( self.term );
	self.close( event );
    }
  event.preventDefault();
 break;

Hoping it can be integrated on future release of autocomplete.

Attachments (0)
Change History (4)

Changed April 30, 2012 02:00PM UTC by scottgonzalez comment:1

The suggested fix is definitely not correct. We should absolutely not prevent the default action all the time. We can add it inside the conditional to require three escapes when the menu is open. This will be slightly different from native autocomplete in IE where 1 = break out of autocomplete, 2 = clear field, 3 = clear form. We end up with 1 = break out of autocomplete, 2 = nothing, 3 = clear field.

I still find escape to clear anything kind of strange on the web.

Changed April 30, 2012 02:26PM UTC by r2363c comment:2

Hello Scott,

I agree with your suggestion and understand you don't wish to prevent default action from IE (as strange it was).

Your suggestion will move the clear form effect from the 2nd escape press to the third, it should significantly reduce the risk of accidental form clear due to a break out of autocomplete, I think it's a good compromise.

Thank you.

Changed April 30, 2012 03:48PM UTC by Scott González comment:3

resolution: → fixed
status: newclosed

Autocomplete: Prevent the default action on escape when the menu is open. Fixes #8282 - Double escape clear IE form, continue Ticket #7643.

Changeset: 4ab7d53b1cfb4e37e3c098ceddc33597b851a88f

Changed November 24, 2012 10:51PM UTC by tj.vantoll comment:4

#8841 is a duplicate of this ticket.