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
This commit is contained in:
Bartosz Dziewoński 2023-10-03 22:03:59 +02:00
parent 364cf45156
commit d27d9ab7b0

View file

@ -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 );
}
} );