From d27d9ab7b06cfb7a950dd1afb90a5674e86c12dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 3 Oct 2023 22:03:59 +0200 Subject: [PATCH] Don't clear comment highlight when clicking on another link When the user clicks anywhere on the page after following a permalink (e.g. from a notification), we would remove the comment highlight and the hash from the URL. Don't do it if the click is on another link: this avoids inserting extra history entries when clicking on several permalinks in a row. Change-Id: I5d77dae4608f74b2be09b9cb92e39a8662529a9f --- modules/controller.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/controller.js b/modules/controller.js index 289431c0f..8d69cfc74 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -548,7 +548,8 @@ function init( $container, state ) { } ); // eslint-disable-next-line no-jquery/no-global-selector $( 'body' ).on( 'click', function ( e ) { - if ( utils.isUnmodifiedLeftClick( e ) ) { + if ( utils.isUnmodifiedLeftClick( e ) && !e.target.closest( 'a' ) ) { + // Remove the highlight and the hash from the URL, unless clicking on another link highlighter.clearHighlightTargetComment( pageThreads ); } } );