Page MenuHomePhabricator

Make the ReferenceTooltips Gadget sub-ref compatible
Open, Needs TriagePublic

Description

Context

Eventually we want to deploy to wikis where the ReferenceTooltips gadget is enabled by default. We want to understand how that Gadget works in these situations and if we can suggest changes to allow compatibility.

Italian Wikipedia which is on our upcoming rollout list uses the en.wiki version of Reference ToolTips. This wiki is important for getting insights on how wikis using sfn-like templates will use Sub-referencing.

See here:
https://it.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js

Task

Event Timeline

WMDE-Fisch renamed this task from Spike: Look into the ReferenceTooltips and other gadget's sub-ref compatibility to Spike: Look into the ReferenceTooltips sub-ref compatibility.Feb 3 2026, 9:31 AM
WMDE-Fisch updated the task description. (Show Details)

Here is a neat way to load the enwiki gadget on another wiki where sub-refs are already enabled. You can copy this to your user's common.js or to the JS console. Make sure to disable the existing Reference Previews feature before.

mw.loader.load( '//en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js?action=raw&ctype=text/javascript' );
mw.loader.load( '//en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.css?action=raw&ctype=text/css', 'text/css' );

Current behavior: The gadget shows only the sub-ref without the main ref.

By the way, the Navigation-Popups-Gadget does have the same problem. But it's not as important because it's targeted at expert users and not enabled by default.

The existing logic for the Reference Previews in the Page-Previews extension can be seen at https://phabricator.wikimedia.org/diffusion/ECIT/browse/master/modules/ext.cite.referencePreviews/createReferenceGateway.js#L31.

Thanks for the tip @thiemowmde. I tried it out and it looks quite funny. We will need to wait for the gadget maintainers to create an update before we deploy to some wikis.
Do you think sharing how Reference Previews integrates sub-refs is enough for the maintainers to be able to make an update or would you suggest we have a more detailed look at the gadget ourselves to ease the transition?

I would suggest a code change on enwiki. This might also help other gadget maintainers as they can see what was changed and copy it, if needed.

https://en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js appears to be largely maintained by WMF staff, by the way.

From a chat on WMF slack with Jon Robson:

The gadget reference tooltips is community maintained (but in practice it is abandonware). There are many copies of it across different projects.

Official advice on what you are allowed to do and how is documented on https://www.mediawiki.org/wiki/Stable_interface_policy/Frontend  (in particular section: How providers can make breaking changes that impact widely used but unmaintained gadgets and Communication of changes to developers of wiki-hosted code)

To summarize guidance in this particular case I'd recommend:

  • Provide a new API to soften the breakage. ie. what API if it existed would have avoided this being a breaking change and will avoid this causing breaking changes again in future ?
  • Give advanced notice (at least 1 month) about the breaking change on Tech News and instructions on how the gadget can be updated using the new API to avoid breakage.
  • Make your change
  • Prepare for the fact that gadgets which are not fixed and causing logspam will need to be disabled by your team (or WMF staff) or fixed.

Italian Wikipedia which is on our upcoming rollout list uses the en.wiki version of Reference ToolTips. See here:
https://it.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js

So this means that a change on en.wiki will support us there. Now we need to figure out how to do that change.

Lina_Farid_WMDE renamed this task from Spike: Look into the ReferenceTooltips sub-ref compatibility to Make the ReferenceTooltips Gadget sub-ref compatible.Feb 17 2026, 9:50 AM
Lina_Farid_WMDE updated the task description. (Show Details)

Just to make this a bit more complete: plwiki is also using the enwiki version (now used by ~30 users). The gadget was enabled by default from 2012 on plwiki, but IIRC we disabled it once MediaWiki implemented reference previews. Perhaps itwiki can discuss to change the default state too.

Also, I think the gadget is not terrible at the moment, as it kind of works. So not terrible, not great ;-)
(enwiki's Gadget-ReferenceTooltips.js on top, built-in preview on the bottom)

obraz.png (431×461 px, 66 KB)

Screen from:
https://de.wikipedia.org/wiki/Nomenklatur_(Biologie)#:~:text=Das%20Art%2DEpitheton%20in%20der%20Botanik%20wird%20%C3%BCblicherweise

Just to make this a bit more complete: plwiki is also using the enwiki version (now used by ~30 users). The gadget was enabled by default from 2012 on plwiki, but IIRC we disabled it once MediaWiki implemented reference previews. Perhaps itwiki can discuss to change the default state too.

Also, I think the gadget is not terrible at the moment, as it kind of works. So not terrible, not great ;-)
(enwiki's Gadget-ReferenceTooltips.js on top, built-in preview on the bottom)

obraz.png (431×461 px, 66 KB)

Screen from:
https://de.wikipedia.org/wiki/Nomenklatur_(Biologie)#:~:text=Das%20Art%2DEpitheton%20in%20der%20Botanik%20wird%20%C3%BCblicherweise

Thanks for pointing that out! Some wikis decided to keep Reference Tooltips as a default gadget because it displays {{sfn}} in a way Reference Previews doesn't (with a pop-up on top of the initial pop-up to show the main reference). We're aware that even wikis who use Reference Previews benefit from updating the gadget for sub-referencing, there are ~500 active users on German Wikipedia still using the gadget. But given that logged-in users can always change their preferences that was less of an issue compared to introducing sub-referencing to wikis where readers cannot use Reference Previews as long as Reference Tooltips is a default gadget. We expect at least some wikis keeping Reference Tooltips as a default for the foreseeable future, that's why we want to provide some help for communities to update the gadget to display both the main reference and sub-ref details.

I made a first draft how the gadget at https://en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js can be updated:

1. Fix for sub-refs

At about line #611 directly after the first .clone( true ); insert this:

const $ol = this.te.$ref.closest( 'ol' );
if ( $ol.hasClass( 'mw-subreference-list' ) ) {
	this.$content = $( '<div>' ).append(
		$ol.siblings( '.reference-text' ).clone( true )
			.css( { display: 'block', 'margin-bottom': '0.7em' } ),
		this.$content
	);
}

What this does: This checks if the current ref is part of a sub-ref list and therefor a sub-ref. If it is, it finds the content of the main ref and shows it above the sub-ref.

Note the extra <div> is needed because this.$content is not necessarily a single element but possibly a collection of elements. We cannot call .prepend( directly. That would add the main ref to multiple places.

2. Fix for main refs

At about line #591 inside of the .filter( function find the line var $this = $( this );. Directly after this line insert:

if ( $this.hasClass( 'mw-subreference-list' ) ) {
	return false;
}

What this does: When hovering a main ref that has additional sub-refs we don't want to see all sub-refs in the popup, only the main ref.

Thank you for the draft! Added to next week's Tech News edition.

@Johannes_Richter_WMDE hello, regarding the entry in tech news:

Wikis that host a copy of the Reference Tooltips gadget are asked to update their version – typically located at MediaWiki:Gadget-ReferenceTooltips.js if existing – as shown here. This makes the gadget compatible with the new sub-referencing feature. Sub-referencing will be gradually rolled-out to more wikis later this year. Other gadgets that work with references might be affected as well.

I will need some more clarification. And unfortunately, this might move it to next week instead (the current edition needs to be frozen). What exactly is the news? The upcoming roll out of Sub-referencing (itself) later this year? The roll out of a new feature of Sub-referencing? Some work done on Reference Tooltips gadget to enable it be compatible with Sub-referencing? Can someone help me understand which aspect is the actual change being announced? And which part becomes the supporting/context information? Thank you.

Hey @STei-WMF! Next week is fine, I believe. The main reason for us posting this is T420938: sub-references will become available on Italian and Czech Wikipedia, probably on April 8. I hope this helps. @Johannes_Richter_WMDE might have more information.

@Johannes_Richter_WMDE hello, regarding the entry in tech news:

Wikis that host a copy of the Reference Tooltips gadget are asked to update their version – typically located at MediaWiki:Gadget-ReferenceTooltips.js if existing – as shown here. This makes the gadget compatible with the new sub-referencing feature. Sub-referencing will be gradually rolled-out to more wikis later this year. Other gadgets that work with references might be affected as well.

I will need some more clarification. And unfortunately, this might move it to next week instead (the current edition needs to be frozen). What exactly is the news? The upcoming roll out of Sub-referencing (itself) later this year? The roll out of a new feature of Sub-referencing? Some work done on Reference Tooltips gadget to enable it be compatible with Sub-referencing? Can someone help me understand which aspect is the actual change being announced? And which part becomes the supporting/context information? Thank you.

Lots of wikis host copies of the Reference Tooltips gadget (instead of just loading the enwiki version) – all of these wikis need to update their copy in order to make sure it works correctly with sub-referencing (which we will roll-out to all wikis later this year). Other wikis using similar gadgets probably need to update their tools as well. Our TechNews entry links the enwiki update (and this ticket) as an example how local interface admins can update the gadget on their wiki. I believe that's what the TechNews entry already says? ("Wikis that host a copy of the Reference Tooltips gadget are asked to update their version...").
Moving the entry to next week's edition is not a problem (we've approached the few projects where immediate action is needed directly), although ideally we could have discussed this earlier, given that I added the entry on Monday...