Page MenuHomePhabricator

Don't load ULS IME on autofocused search bar
Open, MediumPublic

Description

mw.loader.inspect(); on it.wiki main page, unregistered user, unfocused

Tested with Chromium 34.0.1847.132 Russian Fedora aura (265804).

  1. Visit http://it.wikipedia.org/wiki/Pagina_principale, incognito mode, unregistered user, after having opened the developer console (tab is focused).

I. Observed: the search bar is autofocused.

  1. Switch to developer console without keystrokes, e.g. clicking on the JavaScript console.

II. Observed: nothing.

  1. Type mw.loader.inspect(); and enter.

III. Observed:

(index) name size
0 "jquery.uls" "96.4 kB"
1 "jquery.ime" "52.8 kB"
2 "ext.uls.inputsettings" "33.5 kB"
3 "jquery.uls.data" "33.3 kB"
4 "ext.uls.displaysettings" "18.6 kB"
5 "jquery.i18n" "17.3 kB"
6 "mediawiki.jqueryMsg" "15.1 kB"
7 "jquery.suggestions" "11.6 kB"
8 "ext.uls.interface" "8.1 kB"

IV. Expected: ULS resources should be lazy loaded. Until I type alphanumeric characters in the (autofocused) search bar, it can't be assumed I'm going to use it.

Compare:

1-bis) Focus the developer console and click the refresh button.
2-bis) Nothing

V. Observed: Search bar is not focused. ULS is not loaded, see attachment.

Compare:

2-ter) Press tab button
II.

III.

Compare:

2-quater) Press ctrl-shift-J or any other ctrl shortcut.
II-bis. Observed: the IME icon appears.

III.


Version: master
Severity: major

Attached:

Details

Reference
bz65988

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:21 AM
bzimport set Reference to bz65988.
bzimport added a subscriber: Unknown Object (MLST).
Nemo_bis created this task.Jun 1 2014, 8:31 AM

Leaving aside whether adding autofocus on a main page is a good thing or not for a moment, in my testing there doesn't seem to be a way to differentiate between manual focus and autofocus. Searching the internet didn't help either.

Thanks for looking into it so swiftly!

It's indeed tricky and I'm not as competent as to suggest an implementation: as a user however, personally I wouldn't be bothered by the IME being loaded only after my first keystroke.
Pau, do we know from testing what the user expectations are? A data-based decision could perhaps be made by checking whether ime-disable events are proportionally more frequent than ime-enable events on "normal" view action (to non-special pages?) compared to action=edit and whatever? No idea if that helps.

(In reply to Nemo from comment #0)

IV. Expected: ULS resources should be lazy loaded. Until I type alphanumeric
characters in the (autofocused) search bar, it can't be assumed I'm going to
use it.

A problem with lazyloading IME after user types is, the input key transliteration starts/happens only after user types several characters -when the IME is lazyloaded. That make first few characters without IME and then with IME.

(Nemo asked me for input. Thanks.)

One solution that might be possible is to indeed lazyload it when the input field is first used (based on keyup or value change, not focus).

Then, using a callback, once jquery.ime is loaded, read the value entered so far and pass that to jquery.ime immediately (e.g. fast-forward).

To optimise for user experience, you could bind an on('focus') handler still (for browsers not having autofocus, or for when the user focused something else and is going back to the search box, at that point you can anticipate user input and fetch it right away). But you'll have to be careful to bind after autofocus has fired.

Looks like browsers are inconsistent in when they fire autofocus, so binding after it is even harder. Maybe try something hacky like listening for 'focus' only once (using jQuery#one), then see if element.autofocus is set. If so, remove the attribute and bind the event again.

Thanks Krinkle, that looks actionable.

Amir, can you please give an estimate of when this is going to be worked on? If it's not going to be within this month I'll have to work for local workarounds.

It was pointed out that the same behaviour is not immediately reproducible on other wikis like fr.wiki. To reproduce, one indeed needs to add something like it.wiki's JS

// Autofocus nel campo "ricerca" della homepage
$(function() {

if (mw.config.get('wgIsMainPage') && mw.config.get('wgAction') === 'view')
  $('#searchInput').focus();

});

(of which as a workaround I'm asking removal https://it.wikipedia.org/w/index.php?title=Discussioni_MediaWiki%3ACommon.js&diff=66456352&oldid=66261344 ).