https://bugzilla.wikimedia.org/show_bug.cgi?id=65608

            Bug ID: 65608
           Summary: onDomEvent('focus') does not work after jQuery upgrade
           Product: OOjs UI
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: General
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
       Web browser: ---
   Mobile Platform: ---

Steps to reproduce:
1. create OOJS UI textbox widget
2. bind onDomEvent focus handler
3. click on it, and observe the nothingness

jQuery 1.9 has a nasty change in how triggered focus events are handled. There
is some documentation on it at [1] which states "jQuery has always ensured that
a call to .trigger("focus") or .focus() consistently runs any attached event
handlers, even if the element cannot be focused, and jQuery 1.9 continues to do
that."

This is a bald-faced lie. They actually just call the element's native focus()
method and hope for the best. The related code is in $.trigger [2] which calls
the special focus triggering logic [3] which will return false and cancel the
simulated event bubbling of jQuery.

This results in all kind of fun behavior changes, see e.g. [4] Specifically in
the case of OOJS UI textboxes, it seems that setting these events on the parent
element of the textarea instead of the textarea itself prevents the event
triggering somehow.

For a live example, check [5]. This is the textbox in MediaViewer's "Use this
file" menu which should select the text when you click in it. I've verified
that this works with the current core and MediaViewer master, but
resources/lib/jquery/jquery.js rolled back to the old version, but does not
work with the new jQuery version. (Also verified that commenting out line 107
does not fix it, so it is not our manual focus triggering that causes this.)
This commit [6] fixed the issue.



[1]
http://jquery.com/upgrade-guide/1.9/#order-of-triggered-quot-focus-quot-events
[2] https://github.com/jquery/jquery/blob/1.11.0/src/event.js#L281
[3] https://github.com/jquery/jquery/blob/1.11.0/src/event.js#L576
[4] http://bugs.jquery.com/ticket/13363
[5]
https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FMultimediaViewer/f71a591189bb76abb0a178183617be4f33ebacd0/resources%2Fmmv%2Fui%2Fmmv.ui.reuse.share.js#L107
[6] https://gerrit.wikimedia.org/r/134738

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to