Sitelet https://github.com/errbit/errbit/pull/3127
Skip to content

Persist active tab in URL hash across notice pagination - #3127

Open
espen wants to merge 1 commit into
errbit:mainfrom
espen:persist-tab-hash-across-pagination
Open

espen wants to merge 1 commit into
errbit:mainfrom
espen:persist-tab-hash-across-pagination

Conversation

@espen

@espen espen commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Often I want to compare URL params for a group of logged errors. This was tedious as I had to click previous error, switch tab, click previous error, switch tab. This PR will keep focus on selected tab. I am not familiar with pjax so had Claude arrange this PR for me. Let me know if there is a preferred different approach.

By Claude:
The tab links on the problem page set a fragment (#params, #backtrace, etc.) that was never read back, so opening a link with a hash or paging through notices with Older/Newer always reset the view to Summary and dropped the hash from the URL.

Initialize the current tab from location.hash on load, write the hash via history.replaceState when a tab is activated, and re-append it after pjax pagination so the URL stays shareable. Unknown hashes fall back to the Summary tab.

Also fix the pjax setup for the vendored jquery-pjax API: the container must be passed as a string selector ($(document).pjax(links, '#content')) instead of calling .pjax() on the container element, which threw "expected string value for 'container' option" and fell back to full page loads on every pagination click. The replaceState calls preserve history.state so pjax's back/forward handling keeps working.

@espen
espen requested a review from biow0lf as a code owner September 2, 2026 09:14

@mikelolasagasti mikelolasagasti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking suggestion: activateTabbedPanels() calls activateTab(), which already updates the URL with history.replaceState. The additional history.replaceState in pjax:end is therefore redundant and could be removed. activateTabbedPanels() itself should remain.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Malformed fragments can break initialization, and PJAX fallback navigation still loses the active tab.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Persists the selected notice tab through URL hashes and PJAX pagination.

Changes:

  • Initializes and updates the active tab from the URL fragment.
  • Corrects PJAX binding and restores tabs after pagination.
File summaries
File Description
app/assets/javascripts/errbit.js Adds hash-based tab persistence and updates PJAX handling.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/assets/javascripts/errbit.js Outdated
Comment on lines +38 to +40
if (currentTab) {
history.replaceState(history.state, '', '#' + currentTab);
}
Comment thread app/assets/javascripts/errbit.js Outdated
return(false);
});
activateTab($('.tab-bar ul li a.button[rel=' + currentTab + ']'));
var tab = $('.tab-bar ul li a.button[rel=' + currentTab + ']');
@espen
espen force-pushed the persist-tab-hash-across-pagination branch from dbd1eb6 to 0ed4581 Compare September 2, 2026 14:15
@espen

espen commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Updated with suggested changes

@mikelolasagasti

Copy link
Copy Markdown
Contributor

@espen can you update the commit to fix the merge conflict?

@espen
espen force-pushed the persist-tab-hash-across-pagination branch from 0ed4581 to 9a3aebc Compare September 8, 2026 13:35
@espen

espen commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

let me know if there is anything else to fix

The tab links on the problem page set a fragment (#params, #backtrace,
etc.) that was never read back, so opening a link with a hash or paging
through notices with Older/Newer always reset the view to Summary and
dropped the hash from the URL.

Initialize the current tab from location.hash on load, write the hash
via history.replaceState when a tab is activated, and re-append it after
pjax pagination so the URL stays shareable. Unknown hashes fall back to
the Summary tab.

Also fix the pjax setup for the vendored jquery-pjax API: the container
must be passed as a string selector ($(document).pjax(links, '#content'))
instead of calling .pjax() on the container element, which threw
"expected string value for 'container' option" and fell back to full
page loads on every pagination click. The replaceState calls preserve
history.state so pjax's back/forward handling keeps working.

Co-Authored-By: Claude <noreply@anthropic.com>
@espen
espen force-pushed the persist-tab-hash-across-pagination branch from 9a3aebc to 0070a63 Compare September 26, 2026 12:50

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants