You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be related to the dicussion/resolution for #4856, but is a distinct issue.
If you have a Google Address autocomplete input, and trigger focus programatically (e.g. $('input').trigger('focus')) the autocomplete works fine. However, if you add any other focus event listener (event just an empty function, like $('input').on('focus', function() {})) then the autocomplete won't work until manually focused (e.g. through clicking or tabbing).
Link to test case
Test case is at https://jsfiddle.net/bgmrujdt/1/. First autocomplete has a focus event handler, focusing by clicking the button does not work. Second autocomplete doesn't have a focus event handler, focusing by clicking the button does work.
Thanks for the report and the test case! Looks like a real issue that we should investigate along other focus-related issues.
I'm going to tentatively set the milestone to 3.6.1 mostly so that we look at it before the release but it's not guaranteed to be fixed there, especially as we still need to discover the cause.
The issue is reproducible without third party libraries. Attaching a jQuery focus handler on an element makes native handlers attached later not fire at all:
<inputid="input"><buttonid="button">Run the test</button>
changed the title [-]jQuery 3.4.0+ creates focus issues with Google autocompletes[/-][+]jQuery 3.4.0+ silences native focus handlers attached after jQuery ones[/+]on Mar 20, 2023
Activity
mgol commentedon Feb 21, 2022
Thanks for the report and the test case! Looks like a real issue that we should investigate along other focus-related issues.
I'm going to tentatively set the milestone to 3.6.1 mostly so that we look at it before the release but it's not guaranteed to be fixed there, especially as we still need to discover the cause.
mgol commentedon Mar 17, 2023
The issue is reproducible without third party libraries. Attaching a jQuery
focushandler on an element makes native handlers attached later not fire at all:Only
native focus handler 1&jQuery focus handlerwill be logged.Test case: https://jsbin.com/wupovat/1/edit?html,js,console,output
The reason is most likely the
event.stopImmediatePropagation()call at the end of this block:jquery/src/event.js
Lines 580 to 598 in cff2899
This issue is not fixed by my PR #5223 which otherwise fixes a number of other
focusissues.[-]jQuery 3.4.0+ creates focus issues with Google autocompletes[/-][+]jQuery 3.4.0+ silences native focus handlers attached after jQuery ones[/+]mgol commentedon Mar 20, 2023
BTW, since the
clickevent usesleverageNative, it suffers from the same issues: https://jsbin.com/katowor/1/edit?html,js,console,outputEvent: Make trigger(focus/blur/click) work with native handlers
mgol commentedon Mar 26, 2023
PR: #5228
Event: Make trigger(focus/blur/click) work with native handlers
Event: Make trigger(focus/blur/click) work with native handlers
Event: Make trigger(focus/blur/click) work with native handlers
Event: Make trigger(focus/blur/click) work with native handlers