Search and Top Navigation
#7484 closed enhancement (duplicate)
Opened June 16, 2011 02:34PM UTC
Closed November 30, 2011 04:20PM UTC
Last modified November 30, 2011 04:20PM UTC
Mouse and keyboard selection should have the same behavior
Reported by: | dpalita | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.autocomplete | Version: | 1.8.13 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When you select an item in the list using the up/down - enter keys, the focus stays in the input (which is fine).
But when you do this with a mouse click, the focus is momentarily on the item ...
In my use case I have validation bound to the input blur event that triggers an error because it is based on actions taken in the "select" method.
I know there are workarounds (binding on "change" for example) but it would be a pain as my bindings are application wide.
Everything works fine when I put " event.preventDefault(); " at line 5001 before " if ( !$( event.target ).closest( ".ui-menu-item" ).length ) { "
I don't know if it has any side effect on the scroll (which I do not use) but it allows for the same behavior for selections by keyboard or mouse.
Oddly, I had intended to post a bug about the exact same problem yesterday. dpalita beat me to it. The basic problem, as I see it, is if you use the keyboard, you get a "selected" event, and then a "blur". If you use the mouse, you get a "blur" and then a "selected". Hence your "blur" handler only knows something was selected if you use the keyboard.
Since a "blur" without selecting causes an "Add New" on my system, this is of great concern. The "preventDefault" workaround dpalita suggests didn't work in my case.