From 2f92e5d114b0700278044f99308b63eea43d08c3 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Wed, 15 Apr 2020 01:35:00 -0500 Subject: [PATCH] Disable VisualEditor page takeovers while a reply widget is open This allows the unload handler to trigger on these links. Depends-On: If52aa9d619eac08456874fc75c0f6e1adff01246 Bug: T244942 Change-Id: I9904e8af4a60b0f5e9a6e263cd4fd8e1e3fd1f98 --- modules/CommentController.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/CommentController.js b/modules/CommentController.js index 06bd691ce..19f98f862 100644 --- a/modules/CommentController.js +++ b/modules/CommentController.js @@ -131,6 +131,10 @@ CommentController.prototype.setup = function () { $( '.dt-init-replylink-reply' ).attr( { tabindex: '-1' } ); + // Suppress page takeover behavior for VE editing so that our unload + // handler can warn of data loss. + // eslint-disable-next-line no-jquery/no-global-selector + $( '#ca-edit, #ca-ve-edit, .mw-editsection a, #ca-addsection' ).off( '.ve-target' ); logger( { action: 'init', @@ -230,6 +234,11 @@ CommentController.prototype.teardown = function () { $( '.dt-init-replylink-reply' ).attr( { tabindex: '0' } ); + // We deliberately mangled edit links earlier so VE can't steal our page; + // have it redo setup to fix those. + if ( mw.libs.ve && mw.libs.ve.setupEditLinks ) { + mw.libs.ve.setupEditLinks(); + } modifier.removeListItem( this.newListItem ); this.newListItem = null; this.$replyLink.trigger( 'focus' );