@@ -704,10 +704,17 @@ document.addEventListener('htmx:load', function(evt) {
704704 elem . change ( trigger_func ) ;
705705 } ) ;
706706
707- if ( window . location . hash . match ( / # t x n - \d + $ / ) ) {
708- revealHistoryWidget ( ) ;
709- }
707+ if ( window . location . hash ) {
708+ const hash = window . location . hash ;
709+ if ( hash . match ( / # t x n - \d + $ / ) ) {
710+ revealHistoryWidget ( ) ;
711+ }
710712
713+ // Automatically scroll to the specified element
714+ if ( elt . querySelector ( hash ) || elt . querySelector ( '[name="' + hash . substring ( 1 ) + '"]' ) ) {
715+ location . href = location . href ;
716+ }
717+ }
711718
712719 /* inline edit on ticket display */
713720 jQuery ( '.titlebox[data-inline-edit-behavior="link"], .titlebox[data-inline-edit-behavior="click"]' ) . each ( function ( ) {
@@ -933,8 +940,30 @@ jQuery(document).on('click', 'a.search-filter', function (e) {
933940} ) ;
934941
935942// Automatically reveal history widget so anchor links like #txn-586 can work
936- jQuery ( document ) . on ( 'click' , 'a.jump-to-unread' , function ( ) {
937- revealHistoryWidget ( ) ;
943+ jQuery ( document ) . on ( 'click' , 'a.jump-to-unread' , function ( evt ) {
944+ const widget = document . querySelector ( '.htmx-load-widget[hx-get$="/Widgets/Display/History"]' ) ;
945+ if ( widget ) {
946+ const history_mode = widget . querySelector ( '[data-history-mode]' ) ?. getAttribute ( 'data-history-mode' ) ;
947+ // For paginated history, we need to reload widget if the specified txn is not on current page
948+ if ( history_mode === 'page' && widget . getAttribute ( 'data-hx-revealed' ) === 'true' ) {
949+ const matched = evt . target . getAttribute ( 'href' ) . match ( / # ( t x n - ( \d + ) ) $ / ) ;
950+ if ( matched && ! document . querySelector ( '[name="' + matched [ 1 ] + '"]' ) ) {
951+ // Update location first so widget can retrieve the txn id from hash in URL
952+ location . href = evt . target . getAttribute ( 'href' ) ;
953+ const filter_form = widget . querySelector ( 'form.transaction-filter-form' ) ;
954+ if ( filter_form ) {
955+ filter_form . querySelector ( 'input[name=focusTransactionId]' ) . value = matched [ 2 ] ;
956+ htmx . trigger ( filter_form , 'submit' ) ;
957+ setTimeout ( function ( ) {
958+ filter_form . querySelector ( 'input[name=focusTransactionId]' ) . value = '' ;
959+ } , 100 ) ;
960+ }
961+ }
962+ }
963+ else {
964+ revealHistoryWidget ( ) ;
965+ }
966+ }
938967} ) ;
939968
940969// Clip content
0 commit comments