-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Description
Line 688 in 5811e16
$(document).on('click', (event) => { |
$(document).on('click', (event) => {
const urlTarget = $(':target');
if (urlTarget.length === 0) return;
const urlTargetId = urlTarget.attr('id');
if (!urlTargetId) return;
if (!/^(issue|pull)(comment)?-\d+$/.test(urlTargetId)) return;
const $target = $(event.target);
if ($target.closest(`#${urlTargetId}`).length === 0) {
const scrollPosition = $(window).scrollTop();
window.location.hash = '';
$(window).scrollTop(scrollPosition);
window.history.pushState(null, null, ' ');
}
});
This block of code performaces different UI experience with Gitlab issue comment.
When I got focus on certain comment, it gets highlight and hash changed ok.
And when click blank place in the page, the hash changes to empty.
However, I want to keep the same experience as Gitlab done: keep the #hash .
I can .off() the global document click event, if the code provides events namespace, and I only have to add custom code in foot.tmpl instead of replace and modify the whole index.js.
eg: index.js
$(document).on('click.syncemptyhash' , ... ) // or any namespace you like
...
eg:custom,foot.tmpl
<script>
$(document).off('click.syncemptyhash')
</script>
Metadata
Metadata
Assignees
Labels
No labels