Last modified: 2014-05-29 19:38:54 UTC
Created attachment 15448 [details] Screenshot Steps to reproduce: 1.Open a page with VE 2.Make an edit 3.Click on "Switch to source editing " 4.Click on "No, cancel" 5.Now click on the "Cancel" button of the editor 6.Click on "Continue Editing" 7.Now again go to ""Switch to source editing " 8.This time click on "Yes, switch" Observed Result: It does not switch to edit source mode and throws the following errors in the console: Uncaught TypeError: Cannot read property 'css' of null and Uncaught TypeError: Cannot read property 'each' of null See the screenshot attached
Holy crap this is an obscure bug. Steps 3 and 4 (switching to source mode the first time) can be skipped, but other than that every step is necessary. This happens because the switch to source mode button and the cancel button share the same instance of the confirmation dialog. When you click OK in the source mode one, the cancel button code is still listening to the 'ok' event; we need to disconnect that on cancel. Perhaps it would be nicer if these two were combined into one event so we could use .once() and not have to unbind explicitly.
(In reply to Roan Kattouw from comment #1) > Holy crap this is an obscure bug. Steps 3 and 4 (switching to source mode > the first time) can be skipped, but other than that every step is necessary. > As Rummana points out, the second error (with 'each') does not occur if you skip those steps, so there's something else going on too. There's some code in ViewPageTarget that gets run after this.$checkboxes has been cleared. On second inspection, there's a lot more going on. For instance, the 'ok' handler executes twice, and so we attempt to serialize twice.
Change 134546 had a related patch set uploaded by Catrope: Unbind confirm dialog handlers after either of the events fires once https://gerrit.wikimedia.org/r/134546
Change 134546 merged by jenkins-bot: Unbind confirm dialog handlers after either of the events fires once https://gerrit.wikimedia.org/r/134546
Verified the fix in Betalabs
Verified the fix on test 2
Verified the fix in production.