Skip to content

sidebar toggle: slide animation, navbar button, [ hotkey - #1573

Merged
jbtronics merged 7 commits into
Part-DB:masterfrom
samyk:sidebar-toggle
Oct 5, 2026
Merged

jbtronics merged 7 commits into
Part-DB:masterfrom
samyk:sidebar-toggle

Conversation

@samyk

@samyk samyk commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

The sidebar toggle button already hides the left sidebar, but it had a few rough edges:

  • the hidden state was only applied once the Stimulus controller connected, so a hidden sidebar flashed up on every full page load
  • the change was abrupt, and datatables kept their old column widths (and fixed header width) until the window was resized
  • the button was a 10px outlined chevron at the window border, easy to miss (especially in dark mode) and far from the sidebar it belongs to
  • it had no accessible name or state

This PR reworks it:

  • The state is a single class on the root element. A small inline script at the start of the body applies it from localStorage before the sidebar is rendered, so there is no flash, and as Turbo only swaps the body it survives navigations. The storage key is unchanged, so existing preferences are kept.
  • The sidebar slides out and the content column animates to full width (plain CSS, md and up only, so the collapsing sidebar on small screens is untouched; disabled under prefers-reduced-motion). When the transition has finished a resize event is dispatched, so datatables recalculate their columns and fixed header.
  • The button is now a small icon button at the start of the navbar, before the brand (md and up only), with aria-label, aria-controls and aria-expanded. It no longer floats over the page, so it covers no content in either state and does not have to follow the sidebar's width. The icon is the usual sidebar glyph, a window outline with a left pane, drawn as a small inline SVG in the navbar's text colour (Font Awesome Free has no sidebar icon); the pane is filled while the sidebar is shown and empty while it is hidden.
  • Pressing [ anywhere outside a text field toggles the sidebar (ignored on small screens, where the button is not shown). The tooltip mentions the key.

No new translation strings: the existing sidebar.big.toggle is reused.

Update: an earlier version of this PR used a filled tab on the sidebar's edge. As noted in the review it was too prominent and overlapped the main content, so it was replaced by the navbar button described above.

samyk added 5 commits October 3, 2026 14:12
The sidebar toggle button switched the sidebar off with d-none and swapped
the grid classes of the content column from javascript. That had a few
rough edges:

- the state was only applied once the stimulus controller connected, so a
  hidden sidebar flashed up on every full page load
- the change was abrupt, and datatables kept their old column widths (and
  fixed header width) until the window was resized
- the button stayed at the window border, far away from the sidebar it
  belongs to, and had no accessible name or state

The state is now a single class on the root element. A tiny inline script
at the start of the body applies it from localStorage before the sidebar is
rendered, and as turbo only swaps the body it also survives navigations.
The sliding itself is plain css (only for md and up, so the collapsing
sidebar on small screens is untouched), the button sits on the edge of the
sidebar and moves with it. When the transition has finished a resize event
is dispatched, so that datatables and everything else that depends on the
available width recalculates. The storage key is unchanged, so existing
preferences are kept.
The toggle was a 10px wide outlined chevron, which is nearly invisible
(especially in dark mode): nobody finds it. It is now a filled 18x64px tab,
vertically centered on the edge of the sidebar, highlighted on hover.
The handle is a small target; a key is quicker when switching between
browsing the tree and reading a wide table. Like the search hotkey it is
ignored while typing in a field, and it does nothing on small screens,
where the button is not shown.
The check whether the button is shown used offsetParent, which is always
null for a position: fixed element, so the key was ignored everywhere.
@jbtronics

Copy link
Copy Markdown
Member

Thanks for the PR.

Seems useful feature in general, but i think the toggle button is too big and too visually outstanding:

Also with the current width it slightly overlaps with the main content, which i dont think looks good.

image

If you really wanna keep this big button style, i would suggest making it configurable via settings.

@codecov

codecov Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.44%. Comparing base (a27ebb9) to head (c99bd8d).
⚠️ Report is 18 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1573      +/-   ##
============================================
+ Coverage     62.97%   64.44%   +1.46%     
- Complexity    10071    10210     +139     
============================================
  Files           748      762      +14     
  Lines         32315    32711     +396     
============================================
+ Hits          20351    21081     +730     
+ Misses        11964    11630     -334     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

samyk added 2 commits October 4, 2026 16:12
The tab on the sidebar's edge was fixed over the first pixels of the content
column, in both states. As a button at the start of the navbar it covers
nothing, does not move when the sidebar slides, and no longer needs to track
the sidebar's width per breakpoint. The [ key and the persisted state are
unchanged.
The table-columns icon read as a table or layout setting, not as the sidebar.
Font Awesome Free has no sidebar icon, so the usual glyph is drawn inline: a
window outline with a left pane, which is filled while the sidebar is shown
and empty while it is hidden, so the button also shows the state.
@samyk samyk changed the title sidebar toggle: slide animation, visible handle, [ hotkey sidebar toggle: slide animation, navbar button, [ hotkey Oct 4, 2026
@samyk

samyk commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

You're right, the thanks for pushing back on the button style. It started to annoy me too :P

I generally want to avoid adding more settings unless necessary and keeping things inline when reasonable. I've adjusted the toggle to be on the top left in the header row since there's a lot of space there and doesn't intrude on the page itself. Hotkey remains and includes rollover text to show the hotkey.

Update incoming pushed.

CleanShot 2026-10-04 at 16 23 10@2x CleanShot 2026-10-04 at 16 23 34@2x

@jbtronics

jbtronics commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Thanks.

I think that looks better.
I probably need a while to get used to this, but I think its the best solution.

And i really like the color change of the symbol ;)

@jbtronics
jbtronics merged commit 0ce0585 into Part-DB:master Oct 5, 2026
17 checks passed
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.

2 participants