Skip to content

Autocomplete: Close the menu on any outside interactions #1614

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

Conversation

scottgonzalez
Copy link
Member

This ensures that the menu will close if the user interacts with a
draggable, resizable, etc. element since those interactions don't
change focus.

Ref #6642


While testing this, I noticed that clicking on the scrollbar arrows (on an overflow menu) in IE doesn't work properly. Since we can't stop IE from moving focus (

mousedown: function( event ) {
// prevent moving focus out of the text field
event.preventDefault();
// IE doesn't prevent moving focus even with event.preventDefault()
// so we set a flag to know when we should ignore the blur event
this.cancelBlur = true;
), when the user interacts with the scrollbar, the input blurs and then gains focus again. When the field receives focus, the menu jumps back up. As a result, clicking on the scrollbar arrows always results in the menu scrolling to the top. This happens while using the scroll box as well, but since that sets an explicit scroll amount, the menu ends up in the right location after jumping to the top.

We should try to fix that, but it's not related to this change.

This ensures that the menu will close if the user interacts with a
draggable, resizable, etc. element since those interactions don't
change focus.

Ref #6642
@jzaefferer
Copy link
Member

Fix looks good. Let's file a separate ticket for the scrollbar issue. This seems easy enough to test (trigger mousedown inside and outside while menu is open).

@scottgonzalez
Copy link
Member Author

Test added.

var menu = element.autocomplete( "widget" );

$( "body" ).on( "mousedown", function( event ) {
// event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

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

What's this? Build failed due to unused event argument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. That's from debugging. The call shouldn't be commented out.

@scottgonzalez scottgonzalez deleted the autocomplete-outside-click branch October 16, 2015 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants