What is the problem?
If clicking the "Transcribe text" button leads to an error, clicking "Undo transcription" can lead to undesirable results, such as:
- the wikitext is completely cleared or replaced by "null" (see screenshot)
- an older edit of the wikitext is restored
When a request to transcribe the text is made and is successful we save the current contents of the wikitext editor, before replacing it, so we can restore it using undo.
If the request is unsuccessful, clicking undo will restore the wikitext from the last successful transcription request. If any edits had been made in the meantime, these will be lost. If this happens to be the first transcription request, there will be no saved wikitext and the textarea will be replaced by an empty string or null.
Perhaps we should not allow people to undo after an error. We don't change the wikitext if the transcription request returns an error, so there is no need to undo.
Steps to reproduce problem
- In Firefox, open https://en.wikisource.org/w/index.php?title=Page:Prevention_of_Bribery_Ordinance_1970_(Cap._201).pdf/19&action=edit
- Open devtools and go to the Network tab
- Open Request Blocking (circled in red in the screenshot below)
- In the input labelled "Block resource when URL contains" enter: https://ocr.wmcloud.org/
- Click "Transcript text"
- Click "Undo transcription"
Expected behavior: The wikitext is not changed.
Observed behavior: The wikitext is cleared.
Environment
Environment: Wikisource – (ee7fe53) 06:44, 12 August 2022.
