Updating notes edited with Textern fails silently
Summary
When using the Textern Firefox add-on, a note edited through an external editor will reflect the changes made in the editing textarea, as well as the preview tab, but when trying to save the updated note, the original, unedited note is retained. There are no error messages.
Steps to reproduce
- Install Textern and configure it to use your favorite text editor.
- In Firefox, log into GitLab, navigate to an issue of your choice (though it needs to have at least one note that you are allowed to edit)
- Click on the "Edit" pen next to a note's header.
- Focus on the editing textarea, activate Textern, make some changes in the external editor, save and quit.
- Observe how your changes are reflected in the editing textarea.
- Switch to the "Preview" tab, and observe how your changes are also reflected in the rendered HTML.
- Additionally, you may want to inspect the last XHR POST in the console, to verify that the updated markdown got sent for the preview.
- Click "Save".
- Observe how, once you leave editing mode, the note does not change.
- Additionally, you may want to inspect the last XHR PUT request in the console, which reveals that the original note text has been sent, not the updated text.
Further things to try:
-
To confirm that this issue is related to using Textern: Perform the same steps as above, except in step 4, edit directly in the textarea instead of invoking Textern.
-
To confirm that Textern itself is working as intended: Open any other website that has textareas, edit those through Textern, and save. Actually, I believe the fact that the Preview (which also passes through the server via XHR) works flawlessly already rules out a fault in Textern - by the time we click "Save", the modified text has already been consumed by the GitLab client-side JS, so it's not that Textern doesn't send the right things, or somehow breaks the textarea.
-
Perform the same steps as above, but between steps 7 and 8, make additional changes directly in the textarea. Doing so, all the changes, including those made in the external editor, are retained. The additional changes have to be actual changes though, it is not enough to just move the cursor around.
Example Project
n/a
What is the current bug behavior?
Note retains original text.
What is the expected correct behavior?
One of:
- Note shows updated text
- "Edit" and "Preview" tabs do not reflect changes made in external editor (acting as a hint that Textern isn't working as intended)
- Some error message
Possible fixes
I don't know how to fix this, but the additional diagnostic experiments outlined above suggest that the source of the problem is related to some code relying on certain textarea events (key up/down events, maybe?), which will fire upon manual text entry, but not when Textern replaces the textarea's contents wholesale. Since the Preview tab also uses an XHR request, and works fine, I believe comparing the code for "Preview" and "Save" would be a good starting point in solving this.