Page MenuHomePhabricator

mw.util.updateTooltipAccessKeys should add accesskey to tooltip if missing
Closed, ResolvedPublic

Description

Currently mw.util.updateTooltipAccessKeys only updates the tooltip, if it already ends with an access key in square brackets. While mw.util.addPortletLink takes care to provide the title in this format, there are other ocassions (like <input>s created by a script), where you currently have to add the access key explicitely to the title before you can call mw.util.updateTooltipAccessKeys.

If the title doesn't end with something that looks like an access key, mw.util.updateTooltipAccessKeys should just add it, and IMHO do so even if there is no title at all.

So

$foo.append(mw.html.element('input', {id: 'myInput', accesskey: 'x', title: 'Something'}));
mw.util.updateTooltipAccessKeys($('#myInput'));

should work and update the title to "Something [alt-shift-x]" (or whatever).


Version: 1.22.0
Severity: enhancement

Details

Reference
bz48505

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:38 AM
bzimport added a project: MediaWiki-JavaScript.
bzimport set Reference to bz48505.
bzimport added a subscriber: Unknown Object (MLST).
Schnark created this task.May 15 2013, 9:53 AM

If mw.util.updateTooltipAccessKeys were a generic utility to setup accesskey tooltips, then it should do this indeed.

However at this point it was never intended to do that, so classifying this as an enhancement instead.

The method is purely to update (not create) accesskey tooltips.

Though this is not well documented right now, it is the responsibility of the creator of the element (either server-side code in Skin and Linker system or client-side code in mw.util.addPortletLink) to add a placeholder to the tooltip in form of " [x]".

Change 125426 had a related patch set uploaded by Umherirrender:
Add jquery.accessKeyLabel javascript module

https://gerrit.wikimedia.org/r/125426

Change 125426 merged by jenkins-bot:
Add jquery.accessKeyLabel javascript module

https://gerrit.wikimedia.org/r/125426