Skip to content

feat: add adjustable sidebar width with drag handles#1682

Open
sank64 wants to merge 4 commits intomaplibre:mainfrom
sank64:feature/sidebar-resize
Open

feat: add adjustable sidebar width with drag handles#1682
sank64 wants to merge 4 commits intomaplibre:mainfrom
sank64:feature/sidebar-resize

Conversation

@sank64
Copy link

@sank64 sank64 commented Mar 2, 2026

PR 1682 - preview

Summary

Adds draggable resize handles to the sidebar, allowing users to adjust both the total sidebar width and the layer list / properties drawer split. Also fixes a bug where clicking on layer name text did not open properties.
Address all corrections required in #1677

Changes

  • Convert AppLayout from class to functional component
  • Add outer resize handle between sidebar and map
  • Add inner resize handle between layer list and properties drawer
  • Use CSS custom properties for dynamic widths
  • Persist sidebar width and list/drawer ratio to localStorage
  • Fix: clicking layer name text now opens layer properties (dnd-kit dragListeners were intercepting clicks)
  • Extract sidebar helpers to src/libs/sidebar.ts
  • Add unit tests for sidebar helpers
  • Add Cypress e2e test for resize handles

Note: CI e2e failures are all Failed to initialize WebGL - a Chrome 145 headless GPU issue on GitHub Actions, unrelated to this PR.

@sank64 sank64 marked this pull request as draft March 2, 2026 17:27
@sank64 sank64 force-pushed the feature/sidebar-resize branch from 3fdeea3 to 586b2ba Compare March 2, 2026 17:53
@sank64 sank64 changed the title feat: add adjustable sidebar width with drag handle feat: add adjustable sidebar width with drag handles Mar 2, 2026
- Convert AppLayout from class to functional component
- Add outer resize handle between sidebar and map (drag to resize)
- Add inner resize handle between layer list and properties drawer
- Use CSS custom properties for dynamic sidebar/panel widths
- Persist both sidebar width and list/drawer ratio to localStorage
- Fix layer click selection: clicking layer name text now opens properties
- Extract sidebar helpers to src/libs/sidebar.ts
- Add unit tests for sidebar helpers
- Add Cypress e2e test for resize handles
@sank64 sank64 force-pushed the feature/sidebar-resize branch from 586b2ba to 08e73f6 Compare March 2, 2026 17:58
@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 95.51282% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.85%. Comparing base (cb9b7be) to head (a2c5acf).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/libs/sidebar.ts 92.30% 4 Missing ⚠️
src/components/AppLayout.tsx 96.93% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1682      +/-   ##
==========================================
+ Coverage   71.30%   71.85%   +0.54%     
==========================================
  Files         102      103       +1     
  Lines        7002     7167     +165     
  Branches     2146     2172      +26     
==========================================
+ Hits         4993     5150     +157     
- Misses       2006     2014       +8     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 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.

@sank64 sank64 marked this pull request as ready for review March 2, 2026 18:05
className="maputnik-layout-resize-handle"
data-testid="sidebar-resize-handle"
onMouseDown={handleMouseDown}
title="Drag to resize sidebar"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably needs translation too.

Copy link
Author

Choose a reason for hiding this comment

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

You're right — will wrap both resize handle titles with t() and add the corresponding keys to the translation files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some AI generated translations?

Copy link
Author

Choose a reason for hiding this comment

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

I've added translations to the PR

@sank64 sank64 force-pushed the feature/sidebar-resize branch 2 times, most recently from 5bcd6f5 to b33a920 Compare March 3, 2026 15:11
@sank64 sank64 marked this pull request as draft March 3, 2026 15:11
@sank64 sank64 marked this pull request as ready for review March 3, 2026 16:32
@sank64 sank64 marked this pull request as draft March 3, 2026 16:35
@sank64
Copy link
Author

sank64 commented Mar 3, 2026

Hi Harel, I've tried to implement all needed changes. I still get an error on [modals.cy.ts] (1 failing out of 37). I don't see how it is connected to the changes I made in the PR.

  • Kévin

@sank64 sank64 marked this pull request as ready for review March 3, 2026 16:42
@HarelM
Copy link
Collaborator

HarelM commented Mar 4, 2026

Is there a react plugin that can facilitate for this? When I look at it now it looks like a lot of code and I'm wording if this can be solved using some plugin...?

@sank64
Copy link
Author

sank64 commented Mar 5, 2026

Is there a react plugin that can facilitate for this? When I look at it now it looks like a lot of code and I'm wording if this can be solved using some plugin...?

I let you decide. We are using the code I PR to begin with. I wanted to help back the great maputnik team as a thanks for a great project. Unfortunately I won't have time to rewrite the PR or adjust it any more than I did.

@HarelM
Copy link
Collaborator

HarelM commented Mar 6, 2026

I think this should be possible with:
react-resizable-panels

It also has a good drag handle appearance for accessibility.

I'll see if I can find the time for this.
Thanks for taking the time to contribute this!

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