mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-12 01:16:19 +00:00
CommentController: Even better handle clicking links while already commenting
If the user is clicking on a new topic link, and a reply widget is open, attempt to close it instead of doing nothing. Bug: T272545 Change-Id: I1903f5ae4c9e98c4b3a4703ad0e44d772894592a
This commit is contained in:
parent
718457130e
commit
d354b34fa6
|
@ -312,6 +312,15 @@ function init( $container, state ) {
|
|||
return;
|
||||
}
|
||||
|
||||
// If this is a new topic link, and a reply widget is open, attempt to close it first.
|
||||
if ( activeController && c instanceof NewTopicController ) {
|
||||
activeController.replyWidget.tryTeardown().then( function () {
|
||||
activeController = c;
|
||||
c.setup();
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
// If another reply widget is open (or opening), do nothing.
|
||||
if ( activeController ) {
|
||||
return;
|
||||
|
|
|
@ -472,7 +472,7 @@ ReplyWidget.prototype.afterSetup = function () {
|
|||
* Try to teardown the widget, prompting the user if unsaved changes will be lost.
|
||||
*
|
||||
* @chainable
|
||||
* @return {ReplyWidget}
|
||||
* @return {jQuery.Promise} Resolves if widget was torn down, rejects if it wasn't
|
||||
*/
|
||||
ReplyWidget.prototype.tryTeardown = function () {
|
||||
var promise,
|
||||
|
@ -498,10 +498,10 @@ ReplyWidget.prototype.tryTeardown = function () {
|
|||
type: 'nochange'
|
||||
} );
|
||||
}
|
||||
promise.then( function () {
|
||||
promise = promise.then( function () {
|
||||
widget.teardown( true );
|
||||
} );
|
||||
return this;
|
||||
return promise;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue