Page MenuHomePhabricator

Collapsed elements should expand when the browser tries to scroll to a child that is not English
Closed, ResolvedPublic

Description

Even after T276741, headings that contain one or more non-English characters do not expand when the browser tries to scroll to a child.
You can see a live example at https://www.mediawiki.org/w/index.php?title=User:Lens0021/Sandbox&oldid=4610016.
In the example, clicking "English Heading" link in TOC make the collapsed content expand, but clicking "ñ" link don't.

Event Timeline

Looks like we would need to percent-decode location.hash before trying to find the target element.

E.g. when viewing https://www.mediawiki.org/w/index.php?title=User:Lens0021/Sandbox&oldid=4610016#Encabezado_Espa%C3%B1ol, location.hash is "#Encabezado_Espa%C3%B1ol" (even though all browsers display the decoded version in the address bar).

That is actually a little annoying, because then we'd have to handle errors in the case where the fragment is incorrectly encoded.

But there might be a neater solution. Elsewhere in the code, we use the CSS :target selector instead, which lets us rely on the browser to do all that annoying work. I'll submit a patch to do that here as well.

Change 697159 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] jquery.makeCollapsible: Use CSS :target when handling links to collapsed elements

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

Change 697159 merged by jenkins-bot:

[mediawiki/core@master] jquery.makeCollapsible: Use CSS :target when handling links to collapsed elements

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

matmarex claimed this task.

The fix will be deployed to Wikimedia wikis this week, per https://www.mediawiki.org/wiki/MediaWiki_1.37/Roadmap. Thanks for the bug report.