Skip to content

Add resizable sidebar#2853

Merged
katinthehatsite merged 19 commits intotrunkfrom
resizable-sidebar
Apr 21, 2026
Merged

Add resizable sidebar#2853
katinthehatsite merged 19 commits intotrunkfrom
resizable-sidebar

Conversation

@shaunandrews
Copy link
Copy Markdown
Contributor

@shaunandrews shaunandrews commented Mar 19, 2026

image

Proposed Changes

  • Add drag-to-resize on the sidebar's right edge with a custom useSidebarResize hook
  • Sidebar width is continuously adjustable between 150px and 400px
  • Dragging below 100px snaps the sidebar closed; reopening restores the last width
  • Width persists to localStorage across sessions
  • Blue 3px indicator line appears on hover/drag to signal the resize handle
  • Updated toggleMinWindowWidth IPC handler to use the current sidebar width instead of the hardcoded constant
  • CSS transitions are disabled during drag to prevent lag

Testing Instructions

  • Hover over the right edge of the sidebar — a blue line should appear
  • Drag to resize the sidebar between 150px and 400px
  • Drag below ~100px — sidebar should snap closed
  • Use the toggle button to reopen — should restore your last dragged width
  • Quit and relaunch the app — sidebar width should persist
  • Toggle the sidebar closed/open — window should resize by the correct amount

shaunandrews and others added 3 commits March 19, 2026 13:35
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address persistence approach (localStorage vs IPC), toggle window
resize math, transition-during-drag conflict, collapsed state
drag target, and inline style migration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Custom drag-to-resize sidebar with snap-to-close behavior,
localStorage persistence, and a blue hover indicator line.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
shaunandrews and others added 2 commits March 19, 2026 14:09
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@shaunandrews shaunandrews marked this pull request as ready for review March 19, 2026 18:18
Copy link
Copy Markdown
Contributor

@katinthehatsite katinthehatsite left a comment

Choose a reason for hiding this comment

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

Generally, the changes look good to me 👍

I noticed one thing where in some languages that use longer transations, you can see the running sites being mushed together:

Image

In my test, I switched to Ukrainian and resized the sidebar to as narrow as I could before it hides.

Additionally, I would be curious to test this on Windows. I can take a look into that tomorrow.

Comment thread apps/studio/src/hooks/use-sidebar-resize.ts Outdated
@katinthehatsite
Copy link
Copy Markdown
Contributor

For the issue in the sidebar with the sites running, I see it now has been resolved:

Screenshot 2026-04-14 at 3 19 07 PM

@katinthehatsite katinthehatsite requested a review from a team April 14, 2026 13:35
@katinthehatsite
Copy link
Copy Markdown
Contributor

@Automattic/yolo could you please review? I made some changes based in my recommendations but I would appreciate another pair of eyes.

} from 'src/constants';

export function getSavedSidebarWidth(): number {
const saved = localStorage.getItem( LOCAL_STORAGE_SIDEBAR_WIDTH_KEY );
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.

Why did we decide on a local storage approach?
We already have some UI properties (window size) living in the app.json config file.
I don't have anything against local storage, I just believe it should be consistent with our other properties.

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.

I don't have the answer specifically for that bit since it was not originally my PR but it makes sense to be consistent with our other properties. I will check how we can align our approach here 👀

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.

I had a chance to check this a bit further and I think the localStorage approach would be all right here. The sidebar width uses localStorage rather than app.json because it's renderer-side state: it's read synchronously at component init (allowing it to be passed directly as a useState initializer) and never needed by the Main process. windowBounds lives in app.json because Electron's Main process must restore the window size before the renderer exists. Moving sidebar width to app.json would introduce an async IPC to initialize a CSS value, requiring a loading state and added complexity.

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.

That makes a lot of sense, thanks for the explanation! 👍

Copy link
Copy Markdown
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

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

The changes make sense to me, and it overall works well. I added a comment on the snapping.

Comment on lines +61 to +70
if ( finalWidth < SIDEBAR_SNAP_THRESHOLD ) {
// Snap closed — restore the last good width for when it reopens
setSidebarWidth(
dragStartWidth.current > SIDEBAR_MIN_WIDTH ? dragStartWidth.current : SIDEBAR_WIDTH
);
if ( isSidebarVisible ) {
toggleSidebar();
}
return;
}
Copy link
Copy Markdown
Contributor

@gcsecsey gcsecsey Apr 14, 2026

Choose a reason for hiding this comment

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

To me, the UX for snapping the sidebar closed feels a bit strange. When trying to snap it closed, the current threshold feels a bit too high, the user needs to drag the line almost half the way before it registers as snapped. The content beneath also reflows when this happens.

CleanShot.2026-04-14.at.14.41.14-converted.mp4

I'm wondering if we could omit this snap-to-close behavior completely and just rely on the toggle button on top?

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.

I ended up removing the snap behaviour so that now it looks like this:

Screen.Recording.2026-04-21.at.11.23.51.AM.mov

Let me know what you think!

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 14, 2026

📊 Performance Test Results

Comparing 16a9189 vs trunk

app-size

Metric trunk 16a9189 Diff Change
App Size (Mac) 1490.97 MB 1490.98 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk 16a9189 Diff Change
load 1848 ms 1858 ms +10 ms ⚪ 0.0%

site-startup

Metric trunk 16a9189 Diff Change
siteCreation 10135 ms 10122 ms 13 ms ⚪ 0.0%
siteStartup 5942 ms 5955 ms +13 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Copy link
Copy Markdown
Contributor

@katinthehatsite katinthehatsite left a comment

Choose a reason for hiding this comment

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

The changes look good, I also re-requested the review from two other reviewers.

Comment on lines +22 to +23
isMac() && 'pt-[10px]',
! isMac() && 'pt-[38px]',
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.

Why do we need it?

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.

Let me double-check, if I am not mistaken this was related to resolving conflicts with trunk 👀

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.

I removed it as it seems to be an unintended leftover after the conflict resolution

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.

Thanks Kat

Comment thread apps/studio/src/components/app.tsx Outdated
Co-authored-by: Volodymyr Makukha <nei.css@gmail.com>
Copy link
Copy Markdown
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

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

Great improvement, I will increase sidebar width right after this PR is merged :)

Comment thread apps/studio/src/components/app.tsx Outdated
Copy link
Copy Markdown
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thanks for completing the changes @katinthehatsite

@katinthehatsite katinthehatsite merged commit 232d651 into trunk Apr 21, 2026
10 checks passed
@katinthehatsite katinthehatsite deleted the resizable-sidebar branch April 21, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants