Page MenuHomePhabricator

Diff-type selection resets back to "wikitext" when using RevisionSlider
Closed, ResolvedPublicBUG REPORT

Description

The diff interface allows to switch between different view modes: "visual", "wikitext", as well as an "inline" toggle (not depicted). This is a relatively new feature that didn't exist when Revision-Slider was written.

Screenshot from 2023-08-21 11-43-06.png (231×530 px, 15 KB)

The issue: The selection resets back to "wikitext" every time the user interacts with Revision-Slider.

Expected behavior: It should be a sticky selection. At least as long as the user doesn't leave the diff page.

A quick investigation shows that the user's selection is stored in a diff-type option for registered users, and appended as a &diff-type=… URL parameter for anonymous users. Revision-Slider apparently needs to forward this URL parameter in the AJAX request it does to flip to the next diff without reloading the entire page, or make sure the diff is generated with the currently logged in user's options in mind. Not sure why this doesn't happen by default. Is some token necessary?

This is split from T344596 where we fixed another issue related to these buttons.

Event Timeline

I ran into a use case for always including the diff-type= URL parameter by default: to share a link to a specific type of diff like for https://en.wikipedia.org/wiki/Special:Diff/1176144659 which only makes sense as wikitext.

However, it seems that diff-type is currently only about 'inline' vs. 'table' mode for wikitext diffs, and doesn't support 'visual' at all.

The issue: The selection resets back to "wikitext" every time the user interacts with Revision-Slider

Anon users:
I tested the behavior with and without Revision-Slider and it's the same. So the issue described in the ticket description is independent of our extension there. The setting just does not stick.

Loggedin users:
The setting sticks depending on what's saved for the user as a default. So when you set it to Visual once you can use the slider but it will always show a Visual diff. When you change the type to Wikitext then it does not stick. And the other way around - as described above in the ticket description.

Looking into what's happening in the background:

  • When the user toggles the mode, there's always a setting set in the background using AJAX.
  • How we retrieve a diff update in the Revision-Slider is quite hacky: After the user did a change, we always send a AJAX request to get the complete diff page of that change and then replace the #mw-content-text from the result.
  • So we do the same request and also get the same result independent of if the user started with Visual due to their setting or Wikitext.
  • When the user started with Visual though, there will be a 2nd request in the background to retrieve the Visual diff, after the Wikitext diff is retrieved and this will then replace the Wikitext diff on the page.

Changing the mode while using the silder works in so far, that the background request to change the setting is send. But I guess the relevant part missing is some kind of event handler that will be set up once on page load that takes care of "replacing" the Wikitext diff with the Visual diff. - The handler is either set or not on page load and depending on that auto - applies the retrieval of the Visual diff or not.

The inline or table diff mode seems to stick by the way. I see no difference in the behavior with / without RevisionSlider or anon / logged in.

Change 973293 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/extensions/VisualEditor@master] VisualDiff: Remember the current mode when the diff changes

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

Change 973293 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] VisualDiff: Remember the current mode when the diff changes

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

thiemowmde claimed this task.
  NODES
HOME 1
Note 3
os 4
text 15
Users 4
visual 18