Page MenuHomePhabricator

Preview shows categories in alphabetical order instead of original one
Closed, ResolvedPublic

Description

Steps to reproduce:

  1. Find an article with several categories.
  2. Open it for editing in NWE.
  3. Change something.
  4. Preview.

Expected:
The categories should be shown in source order.

Actual:
The categories are shown in alphabetical order.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Deskana subscribed.

A problem with the preview HTML, i.e. Parsoid?

Vvjjkkii renamed this task from Preview shows categories in alphabetical order instead of original one to 0laaaaaaaa.Jul 1 2018, 1:03 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from 0laaaaaaaa to Preview shows categories in alphabetical order instead of original one.Jul 2 2018, 9:47 AM
CommunityTechBot raised the priority of this task from High to Needs Triage.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.

A problem with the preview HTML, i.e. Parsoid?

I don't think so. Parsoid preserves source order.

[subbu@earth:~/work/wmf/parsoid] echo "a [[Category:Foo]] [[Category:Bar]]" | parse.js --normalize=parsoid

<p>a</p>
<link rel="mw:PageProp/Category" href="./Category:Foo"/> <link rel="mw:PageProp/Category" href="./Category:Bar"/>

See the output order when fed HTML.

[subbu@earth:~/work/wmf/parsoid] echo "a [[Category:Foo]] [[Category:Bar]]" | parse.js --normalize=parsoid | parse.js --html2wt

a
[[Category:Foo]] 
[[Category:Bar]]

Indeed, ve.init.mw.ArticleTarget.prototype.renderCategories does the sorting, and actually seems to do so on purpose, though I don't really understand why (since the hidden cat flag is determined async, the categories might be in random order after the promises are all done, but sorting according to either the sortkey or the category name just doesn't make sense).

Change 444599 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] init.mw.ArticleTarget: sort categories correctly in renderCategories

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

Change 444599 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] init.mw.ArticleTarget: sort categories correctly in renderCategories

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

Change 444920 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] init.mw.ArticleTarget: make sure renderCategories preserves order

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

Change 444920 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] init.mw.ArticleTarget: make sure renderCategories preserves order

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

Deskana triaged this task as Medium priority.