Skip to content

imp: web: preserve sidebar position during navigation#2644

Open
acinader wants to merge 1 commit into
simonmichael:mainfrom
acinader:codex/hledger-web-sidebar-state
Open

imp: web: preserve sidebar position during navigation#2644
acinader wants to merge 1 commit into
simonmichael:mainfrom
acinader:codex/hledger-web-sidebar-state

Conversation

@acinader

@acinader acinader commented Jun 6, 2026

Copy link
Copy Markdown

This is an exploratory draft PR for hledger 2.x main.

When reviewing a large chart of accounts in hledger-web, clicking account links currently reloads the full page and resets the account sidebar position. This patch keeps the existing server-rendered links and progressively enhances same-origin /journal and /register navigation when JavaScript is available:

  • keep ordinary hrefs for no-JS / failed-JS fallback behavior
  • fetch the target page as HTML
  • replace only #main-content
  • refresh the sidebar account table so the active account highlight updates
  • preserve the existing sidebar container and scrollTop
  • use history.pushState / popstate for URLs and browser back/forward

I also made #sidebar-menu a bounded vertical scroll container.

Related context:

Checks run locally:

  • node -c hledger-web/static/hledger.js
  • git diff --check
  • cabal v2-build hledger-web --enable-tests --allow-newer --constraint='persistent >=2.17'
  • cabal v2-test hledger-web:apptest --allow-newer --constraint='persistent >=2.17'

The Cabal build/test needed the persistent >=2.17 constraint because this machine only has GHC 9.14.1, and the default plan selected persistent-2.11.0.4, which did not compile with this toolchain. With the local dependency workaround, hledger-web built and its test suite passed: 4 examples, 0 failures.

Manual smoke check:

  • Ran the patched hledger-web against a generated local journal with 81 accounts.
  • Confirmed the patched hledger.js and hledger.css were served.
  • Manually tried sidebar account navigation in the in-app browser and found it worked well in first use.

Still worth checking before considering this ready:

  • more real-world use on larger account trees
  • browser back/forward behavior
  • register chart rendering after AJAX navigation
  • add-transaction modal behavior when hledger-web is not in view-only mode
  • sidebar hidden/shown cookie behavior
  • behavior with a non-root --base-url

AI assistance disclosure:

This patch and PR text were prepared with OpenAI/Codex assistance. Approximate usage: several interactive Codex turns for research, patch drafting/refinement, local testing, and PR preparation. I understand the project currently prefers not to accept OpenAI-assisted work; I am opening this as a draft for review/discussion and to learn whether this direction is useful.

@acinader acinader marked this pull request as ready for review June 13, 2026 07:26
@acinader

Copy link
Copy Markdown
Author

I have been using it for a few weeks now.

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.

1 participant