mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-13 18:37:07 +00:00
CommentController: Better handle clicking links while already commenting
Bug: T272389 Change-Id: If28a6cce250dca4810de3f51c0a2a4587d00649e
This commit is contained in:
parent
234198d9b1
commit
2798ee73f4
|
@ -109,15 +109,33 @@ CommentController.prototype.onReplyLinkClick = function ( e ) {
|
||||||
// Only handle keypresses on the "Enter" or "Space" keys
|
// Only handle keypresses on the "Enter" or "Space" keys
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Allow users to use multiple reply widgets simultaneously.
|
if ( e.type === 'click' && ( e.which !== OO.ui.MouseButtons.LEFT || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) ) {
|
||||||
// Currently submitting a reply from one widget would also destroy the other ones.
|
// Only handle unmodified left clicks
|
||||||
// eslint-disable-next-line no-jquery/no-class-state
|
|
||||||
if ( this.$pageContainer.hasClass( 'dt-init-replylink-open' ) ) {
|
|
||||||
// Support: IE 11
|
|
||||||
// On other browsers, the link is made unclickable using 'pointer-events' in CSS
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
// TODO: Allow users to use multiple reply widgets simultaneously.
|
||||||
|
// Currently submitting a reply from one widget would also destroy the other ones.
|
||||||
|
|
||||||
|
// If the reply widget is already open, activate it.
|
||||||
|
// Reply links are also made unclickable using 'pointer-events' in CSS, but that doesn't happen
|
||||||
|
// for new section links, because we don't have a good way of visually disabling them.
|
||||||
|
// (And it also doesn't work on IE 11.)
|
||||||
|
if ( this.opened ) {
|
||||||
|
// Show and focus the widget
|
||||||
|
this.replyWidget.scrollElementIntoView( { padding: scrollPadding } );
|
||||||
|
this.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If another reply widget is open (or opening), do nothing.
|
||||||
|
// eslint-disable-next-line no-jquery/no-class-state
|
||||||
|
if ( this.$pageContainer.hasClass( 'dt-init-replylink-open' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setup();
|
this.setup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -224,6 +242,7 @@ CommentController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
||||||
replyWidget.setup( data );
|
replyWidget.setup( data );
|
||||||
|
|
||||||
this.replyWidget = replyWidget;
|
this.replyWidget = replyWidget;
|
||||||
|
this.opened = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -250,6 +269,7 @@ CommentController.prototype.teardown = function ( abandoned ) {
|
||||||
}
|
}
|
||||||
modifier.removeAddedListItem( this.newListItem );
|
modifier.removeAddedListItem( this.newListItem );
|
||||||
this.newListItem = null;
|
this.newListItem = null;
|
||||||
|
this.opened = false;
|
||||||
if ( abandoned ) {
|
if ( abandoned ) {
|
||||||
this.$replyLink.trigger( 'focus' );
|
this.$replyLink.trigger( 'focus' );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue