Page MenuHomePhabricator

Edit Recovery does not work with Syntax Highlighting enabled
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

  • Your edits are not recovered
  • An entry is not created in IndexedDB

What should have happened instead?:

  • Your edits are recovered
  • An entry is created in IndexedDB

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

  • Disabling syntax highlighting and retrying the above repro steps will result in edits being recovered as expected

Event Timeline

@TheDJ it's already using the textSelection API, but Edit Recovery's change handler is never called when CodeMirror is active. It looks like CodeMirror only actually updates (with codeMirror.save()) the underlying textarea on window.beforeunload, and even then it does it with textarea.value rather than textSelection.

One way to do it might be to add a hook in edit.js where we're adding event handlers, so that CM can add itself using its own change event. We probably want a hook there anyway.

Change 942782 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] EditRecovery: add editRecovery.loadEnd JS hook

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

Change 942783 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/CodeMirror@master] Use editRecovery.loadEnd JS hook to add change handler

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

Change 942782 merged by jenkins-bot:

[mediawiki/core@master] EditRecovery: add editRecovery.loadEnd JS hook

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

Change 942783 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] Use editRecovery.loadEnd JS hook to add change handler

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

Confirmed working on the beta cluster too :-)

@Samwilson @TheresNoTime I changed the highlighted word "cute" to "adorable". I went to a new article and closed the tab and it still has the word I changed it to along with an entry for the IndexedDB. As for the IndexedDB entry, is there something I can see that I changed it too like how I changed "cute" to "adorable" or does it just show an entry that it's saved?

T342882_EditRecovery_SyntaxHighlighting.png (655ร—1 px, 372 KB)

@Samwilson @TheresNoTime I changed the highlighted word "cute" to "adorable". I went to a new article and closed the tab and it still has the word I changed it to along with an entry for the IndexedDB. As for the IndexedDB entry, is there something I can see that I changed it too like how I changed "cute" to "adorable" or does it just show an entry that it's saved?

T342882_EditRecovery_SyntaxHighlighting.png (655ร—1 px, 372 KB)

I've found Firefox to be better for this. You can right click the indexeddb field you are interested in and "Copy".

firefox_copying_edit_recovery_data.png (1ร—1 px, 352 KB)

@Samwilson Edits are recovered and an IndexDB is created. Moving this to Done. Thanks for your work!

Status: โœ… PASS
Environment: Prod
OS: macOS Ventura, Windows 11
Browser: Chrome 116, Firefox 115, Safari 16.6, Edge 115
Device: MBP
Emulated Device:: BrowserStack for Windows
Test Link:
https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Bear&action=edit

Cleared out DB with each test. Speeds with No Throttle, fast and slow 3G

ChromeSafariFirefoxEdge
2023-08-21_06-05-27.png (2ร—3 px, 1 MB)
2023-08-21_06-27-14.png (1ร—3 px, 937 KB)
firefox_copying_edit_recovery_data.png (1ร—1 px, 352 KB)
2023-08-21_06-24-17.png (1ร—2 px, 2 MB)

Disabling Syntax

2023-08-21_05-53-16.png (2ร—3 px, 1 MB)