Merge "Don't clear target comment highlight when Ctrl-clicking"

This commit is contained in:
jenkins-bot 2022-02-08 19:49:44 +00:00 committed by Gerrit Code Review
commit e82a4d86f3
3 changed files with 15 additions and 4 deletions

View file

@ -136,7 +136,7 @@ ReplyLinksController.prototype.isActivationEvent = function ( e ) {
// Only handle keypresses on the "Enter" or "Space" keys
return false;
}
if ( e.type === 'click' && ( e.which !== OO.ui.MouseButtons.LEFT || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) ) {
if ( e.type === 'click' && !utils.isUnmodifiedLeftClick( e ) ) {
// Only handle unmodified left clicks
return false;
}

View file

@ -288,7 +288,7 @@ function initTopicSubscriptions( $container ) {
// Only handle keypresses on the "Enter" or "Space" keys
return;
}
if ( e.type === 'click' && ( e.which !== OO.ui.MouseButtons.LEFT || e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ) ) {
if ( e.type === 'click' && !utils.isUnmodifiedLeftClick( e ) ) {
// Only handle unmodified left clicks
return;
}
@ -889,7 +889,7 @@ function init( $container, state ) {
} );
// eslint-disable-next-line no-jquery/no-global-selector
$( 'body' ).on( 'click', function ( e ) {
if ( e.which === OO.ui.MouseButtons.LEFT ) {
if ( utils.isUnmodifiedLeftClick( e ) ) {
clearHighlightTargetComment( parser );
}
} );

View file

@ -601,6 +601,16 @@ function compareRangesAlmostEqualBoundaries( a, b, boundary ) {
return !foundContent;
}
/**
* Check whether a jQuery event represents a plain left click, without any modifiers
*
* @param {jQuery.Event} e
* @return {boolean} Whether it was an unmodified left click
*/
function isUnmodifiedLeftClick( e ) {
return e.which === OO.ui.MouseButtons.LEFT && !( e.shiftKey || e.altKey || e.ctrlKey || e.metaKey );
}
module.exports = {
NEW_TOPIC_COMMENT_ID: NEW_TOPIC_COMMENT_ID,
isBlockElement: isBlockElement,
@ -619,5 +629,6 @@ module.exports = {
getTitleFromUrl: getTitleFromUrl,
linearWalk: linearWalk,
linearWalkBackwards: linearWalkBackwards,
compareRanges: compareRanges
compareRanges: compareRanges,
isUnmodifiedLeftClick: isUnmodifiedLeftClick
};