Page MenuHomePhabricator

Editing lede section with an infobox takes you to the infobox, not the first paragraph
Closed, ResolvedPublic

Description

Due to the DOM manipulation Mobile Frontend does to switch the lede and infobox, editors may be confused to see the infobox first when opening the lede section.

The correct fix would be something like T223116, but failing that we could just scroll to the first paragraph.

Event Timeline

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

Change 517751 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] MobileArticleTarget: Scroll past the infobox on load

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

Change 517751 abandoned by Bartosz Dziewoński:
MobileArticleTarget: Scroll past the infobox on load

Reason:
Needs a different approach, see task.

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

So my initial approach here was to scroll past the infobox, which fixes the problem if the lead paragraph was moved before the infobox by the lead paragraph transformation, but there are other cases that cause similar problems: the position of the lead paragraph is also affected by invisible templates and slugs caused by the presence of hatnote templates (both only shown in edit mode). Instead we should scroll to the lead paragraph: this approach also works in those cases.

Detecting the lead paragraph is slightly trickier than detecting the infobox. To do this I've reimplemented MobileFrontend's MoveLeadParagraphTransform::identifyLeadParagraph() in JavaScript, so that we can run it on the edit mode HTML. (While trying to understand the original code, I noticed a few inefficiencies and wrote patches for them as well, see the dependencies of the patch.)

I'm putting the resulting code in the MobileFrontend repo, for two reasons: it increases the chances that someone will keep the two versions in sync ;) , and because the original code is under GNU GPL license while most of VE is under MIT, so we would probably have to put it in a separate file with a separate license notice or do some other annoying things.

Change 526804 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/MobileFrontend@master] mobile.init/editor: Scroll to the lead paragraph on load

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

Change 526804 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] mobile.editor.overlay: Scroll to the lead paragraph on load

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

@matmarex I note that the scrolling doesn't work for logged out users (I assume due to the login overlay we show).

@matmarex I note that the scrolling doesn't work for logged out users (I assume due to the login overlay we show).

Good catch, Ed. Creating a ticket to track this. Tho, if you've already got something written, please close this task as a duplicate: T231848