Skip to content

Commit 428f103

Browse files
committed
fix(webapp): animate the side menu scroll body's right padding on collapse
The left padding of the scroll body interpolated smoothly with --sm-collapse, but the right-hand spacing came from a reserved scrollbar gutter that is a fixed width and gets dropped abruptly when the scrollbar is hidden on collapse, so it jumped instead of animating. Drop the reserved gutter and drive the right padding with the same variable as the left, so both edges animate together. The thin scrollbar still appears when the nav list overflows; it just no longer reserves a fixed gutter while idle.
1 parent 2c264d4 commit 428f103

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,6 @@ const DRAG_CLICK_THRESHOLD = 4;
209209

210210
/** Left/right padding of the pinned top section + scroll body, interpolated 10px → 4px by --sm-collapse. */
211211
const SIDE_MENU_PAD_X = `calc(0.625rem - 0.375rem * var(--sm-collapse, 0))`;
212-
/**
213-
* Right padding of the scroll body, interpolated 0 → 4px by --sm-collapse: expanded, the reserved
214-
* scrollbar gutter provides the right-side space; collapsed there is no gutter, so this keeps the
215-
* rail buttons inset symmetrically (matching the left padding) instead of touching the edge.
216-
*/
217-
const SIDE_MENU_SCROLL_PAD_RIGHT = `calc(0.25rem * var(--sm-collapse, 0))`;
218212
/**
219213
* The selector rows' hover chevron: its 16px of layout width follows --sm-label-opacity so an
220214
* invisible chevron can never hold width mid-drag and push the row's overflow clip edge into the
@@ -737,14 +731,19 @@ export function SideMenu({
737731
<div
738732
className={cn(
739733
"min-h-0 overflow-y-auto pt-2.5",
734+
// No `scrollbar-gutter-stable`: a reserved gutter is a fixed width that can't animate and
735+
// is dropped abruptly when `scrollbar-none` kicks in on collapse, so the right-hand
736+
// spacing jumped instead of following the drag. Without it the right padding below drives
737+
// the spacing and animates symmetrically with the left; the thin scrollbar still appears
738+
// when the list overflows, it just no longer reserves space when it isn't scrolling.
740739
isCollapsed
741740
? "scrollbar-none"
742-
: "scrollbar-gutter-stable scrollbar-thin scrollbar-track-transparent scrollbar-thumb-surface-control"
741+
: "scrollbar-thin scrollbar-track-transparent scrollbar-thumb-surface-control"
743742
)}
744743
>
745744
<div
746745
className="mb-6 flex w-full flex-col gap-4 overflow-hidden"
747-
style={{ paddingLeft: SIDE_MENU_PAD_X, paddingRight: SIDE_MENU_SCROLL_PAD_RIGHT }}
746+
style={{ paddingLeft: SIDE_MENU_PAD_X, paddingRight: SIDE_MENU_PAD_X }}
748747
>
749748
<div className="w-full space-y-0">
750749
<SideMenuItem

0 commit comments

Comments
 (0)