Skip to content

Commit 650abb6

Browse files
committed
Tweak the behavior of "Jump to Unread" links for clicked history
Instead of adding "ForceShowHistory=1" to the URL (which would reload the entire page), this commit tweaked the behavior to implicitly trigger the "Show ticket history" link, which only updates the history widget. Since we now find and scroll to the anchor after every htmx load, the "anchor scroll" code in ClickToShowHistory is no longer needed.
1 parent 5dd1dc8 commit 650abb6

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

share/html/Elements/RT__Ticket/ColumnMap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ $COLUMN_MAP = {
420420
my $link = RT->Config->Get('WebPath');
421421
$link .= $session{'CurrentUser'}->Privileged ? '/Ticket/Display.html?id=' : '/SelfService/Display.html?id=';
422422
$link .= $self->id . '&MarkAsSeen=1&Anchor=txn-' . $first_unread->id;
423-
$link .= '&ForceShowHistory=1' if RT->Config->Get( 'ShowHistory', $session{'CurrentUser'} ) eq 'click';
424423

425424
my $title = loc("Jump to Unread & Mark as Seen");
426425
return \( '<a data-bs-toggle="tooltip" data-bs-title="' . $title . '" href="' . $link . '"><b>' ),

share/html/Ticket/Elements/ClickToShowHistory

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@
5555
jQuery(function(){
5656
jQuery('#deferred_ticket_history a.show-ticket-history').click(function() {
5757
jQuery('#deferred_ticket_history').text(<% loc('Loading...') |n,j%>);
58-
htmx.ajax('GET', <% $url |n,j %>, { source: '#deferred_ticket_history', target: '#deferred_ticket_history' }).then(() => {
59-
if ( window.location.hash.match(/#txn-\d+/) ) {
60-
var hash = window.location.hash;
61-
// Refresh anchor so browser can jump to it accordingly
62-
window.location.hash = '';
63-
window.location.hash = hash;
64-
}
65-
});
58+
htmx.ajax('GET', <% $url |n,j %>, { source: '#deferred_ticket_history', target: '#deferred_ticket_history' });
6659
return false;
6760
});
6861

share/html/Ticket/Elements/ShowUpdateStatus

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
<span class="new-messages-buttons">
5757
% my $ShowHistory = RT->Config->Get( 'ShowHistory', $session{'CurrentUser'} );
5858
% my $url = RT->Config->Get('WebPath') . "/$DisplayPath/Display.html?id=" . $Ticket->id;
59-
% if ( $ShowHistory eq 'click' ) {
60-
% $url .= '&ForceShowHistory=1';
61-
% }
6259
<a
6360
% if ( RT::Interface::Web::RequestENV('REQUEST_URI') eq $url ) { # URL doesn't change, no need to reload
6461
hx-boost="false"

share/static/js/init.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,12 @@ document.addEventListener('htmx:load', function(evt) {
707707
if (window.location.hash) {
708708
const hash = window.location.hash;
709709
if (hash.match(/#txn-\d+$/)) {
710-
revealHistoryWidget();
710+
if ( document.querySelector('#deferred_ticket_history a.show-ticket-history') ) {
711+
htmx.trigger(document.querySelector('a.show-ticket-history'), 'click');
712+
}
713+
else {
714+
revealHistoryWidget();
715+
}
711716
}
712717

713718
// Automatically scroll to the specified element
@@ -960,6 +965,10 @@ jQuery(document).on('click', 'a.jump-to-unread', function (evt) {
960965
}
961966
}
962967
}
968+
else if ( widget.querySelector('#deferred_ticket_history a.show-ticket-history') ) {
969+
location.href = evt.target.getAttribute('href');
970+
htmx.trigger(widget.querySelector('a.show-ticket-history'), 'click');
971+
}
963972
else {
964973
revealHistoryWidget();
965974
}

0 commit comments

Comments
 (0)