Steps to replicate the issue (include links if applicable):
- go to https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-gadgets
- enable edittop ("Add an [edit] link for the lead section of a page")
- go to https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-editing
- set editing mode to "remember my last editor"
- go to https://en.wikipedia.org/wiki/Thierry_Henry
- click edit
- click read
What happens?:
Edittop vanished.
What should have happened instead?:
Edittop still there.
The visual editor can do the same thing if it's the only editor. The problem doesn't seem to trigger when the editing mode is set to "show me both editor tabs" and both editors are available.
Edit: for the sake of completeness (as the task description/title was updated): I originally discovered this issue while testing my own script, Factotum. I figured any script/gadget that resides in #firstHeading would be affected and testing edittop proved me right. As edittop is better known I used that for the example. Kudos for the quick patch btw.
Edit 2: the updated reproduction steps could (sort of) fail: if you haven't enabled the 2017 wikitext editor and your last editor was the 2010 source editor, you'd only have an "edit source" (not "edit") link which doesn't load VE and thus wouldn't trigger this issue.