20

Since a few days or weeks ago, when I am editing a post and somebody else submits an edit (directly, no review needed), I see a banner above my editor:

There has been an edit made to this post. Click to load

(it's probably not literally that, forgive me not remembering the text correctly)

However, even if I don't click that banner but click inside the editor to navigate the cursor or just go on typing, the page reloads and kicks me out of the editor, sending me back to the standard post view with the other person's edit applied.

All my work so far has vanished. If I click on the edit link again, I can edit the current version from scratch, but what I've written before is gone.

This is a serious issue, please stop trashing the work of editors if another concurrent edit gets submitted.

  • First, you should make the page reload only if the banner above the editor gets clicked, not on any other click/typing event anywhere else.

  • Second, please cache the editor's unsubmitted changes if they click the banner and reload it (or ask whether to load it or the new post revision) when they click on the edit link afterwards again.

4
  • How many words did you try to edit before you were kicked out?
    – Rathony
    Commented Sep 30, 2016 at 12:03
  • 4
    I suspect this might be an unintended side effect of the recent change that made clicking the body of an edited post reload it. If that's the case, the fix would be to disable the click handler when the inline post editor is active. Commented Sep 30, 2016 at 12:42
  • @IlmariKaronen Good guess, I think the described behaviour might have started around the same time this got introduced. Commented Sep 30, 2016 at 13:20
  • @Rathony I experienced it on both minor edits (few characters) as well as substantial rewordings. Commented Sep 30, 2016 at 13:20

1 Answer 1

8

This is indeed a (presumably) unintended side effect of the recent change that made clicking any part of an edited post reload it. The problem is that the current implementation is not aware of the inline post editor, and thus triggers a reload on any click even if the post is being edited.

The following single-line patch to realtime-se.js should (AFAICT) fix this bug:

--- realtime-se.js  2016-10-03 22:30:33.157595337 +0300
+++ realtime-se.fixed.js    2016-10-03 22:33:41.834822358 +0300
@@ -799,7 +799,7 @@
             }
             $(document).trigger('refreshEdit', post.id);
         };
-        div.click(func);
+        if (div.find('.inline-editor').length < 1) div.click(func);
         notificationDiv.prependTo(div).find('a').click(function (e) {
             e.stopPropagation();
             func();
2
  • 2
    Thank you, also needed to make sure to not call div.off in the func() (though that might not have caused issues, better to be thorough). We're not setting up the click handler if the inline editor closes, but since the bar stays permanently, that alight inconsistency shouldn't be an issue. Commented Oct 5, 2016 at 17:10
  • @MichaelStum: Thanks! I do believe that removing a non-existent event handler with .off() indeed simply does nothing; the documentation, while not quite outright saying so, at least strongly implies it. But you're right, when not sure, it's better to be cautious. Commented Oct 5, 2016 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .