Skip to content

X2-14336 | fix(sidebar): fill the rail with the solid button and allow touch drags - #452

Open
rushi wants to merge 1 commit into
xola:masterfrom
rushi:X2-14336-sidebar-button-fill
Open

rushi wants to merge 1 commit into
xola:masterfrom
rushi:X2-14336-sidebar-button-fill

Conversation

@rushi

@rushi rushi commented Sep 8, 2026

Copy link
Copy Markdown
Member

Follow-up to #448. Three defects in the sidebar surfaced while reviewing x2-seller#6897, which worked around all of them in the consumer.

Solid button never filled the rail

A <button> resolves width: auto to fit-content rather than filling its containing block. Sidebar.Link carries w-full for that reason; the solid branch of Sidebar.Button had no width at all, so it rendered at its text width and sat at the left edge with dead space beside it.

Measured against a 188px containing block, before this change:

rail available solid button dead space
64 40 40 12 (fits by coincidence)
150 126 81.5 56.5
173 149 81.5 79.5
200 176 117.5 70.5

Takes w-[calc(100%-16px)] rather than w-full because the solid treatment also carries mx-2, and 16px is that margin on the config's px spacing scale.

Resize handle ignored touch

The handle had no touch-action, so a touch drag was claimed by the browser as a scroll and arrived as pointercancel. Dragging the rail did nothing on a touchscreen. preventDefault in the pointerdown handler does not suppress that; only the CSS property does. finishResize already handled the cancel path, so the gesture failed silently rather than latching.

Rotation discarded a chosen width

resolveCrossingWidth guarded the downward crossing with hasIntentBelow but not the upward one. Dragging the rail to 120px in portrait and rotating to landscape replaced it with lastExpandedWidth. Both directions now honour the flag, covered by a new case in sidebarWidth.test.js.

Verification

34 tests pass in sidebarWidth.test.js, eslint clean, npm run build clean. The rail-fill and centring numbers above come from measuring the real component in Chrome at each band.

…w touch drags

A button resolves `width: auto` to fit-content rather than filling its
containing block, so `Sidebar.Button appearance="solid"` rendered at its
text width and sat at the left edge of the rail with up to 80px of dead
space beside it. Sidebar.Link already carried `w-full` for this reason;
the solid branch had no width at all. It takes `w-[calc(100%-16px)]`
rather than `w-full` because the solid treatment also carries `mx-2`.

The resize handle had no `touch-action`. A touch drag was claimed by the
browser as a scroll and arrived as `pointercancel`, so dragging the rail
did nothing on a touchscreen. `preventDefault` in the pointerdown handler
does not suppress that; only the CSS property does.

resolveCrossingWidth guarded the downward crossing with `hasIntentBelow`
but not the upward one, so rotating a tablet from portrait to landscape
replaced a width the user had just dragged with the remembered expanded
width. Both directions now honour the flag.
@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/xola/ui-kit/@xola/ui-kit@452

commit: f1f4fb9

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f79592c2-bd0b-4cc0-bfca-30d01e4fd13a

📥 Commits

Reviewing files that changed from the base of the PR and between 0b2eee6 and f1f4fb9.

📒 Files selected for processing (4)
  • src/components/Sidebar/Sidebar.Button.jsx
  • src/components/Sidebar/Sidebar.jsx
  • src/components/Sidebar/sidebarWidth.js
  • src/components/Sidebar/sidebarWidth.test.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • xola/x2-seller (manual)

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary

  • Set solid sidebar button width to calc(100%-16px) to account for mx-2.
  • Added touch-none to the resize handle to prevent touch scrolling from canceling resize gestures.
  • Preserved user-selected widths when rotation crosses the viewport breakpoint.
  • Added regression coverage for crossing-up width resolution.

Verification

  • 34 sidebarWidth.test.js tests passed.
  • ESLint passed.
  • Build passed.

Walkthrough

The sidebar updates its solid button width, prevents touch gesture cancellation during resizing, and preserves user-selected widths when crossing the responsive threshold.

Changes

Sidebar behavior

Layer / File(s) Summary
Sidebar presentation and touch resizing
src/components/Sidebar/Sidebar.Button.jsx, src/components/Sidebar/Sidebar.jsx
The solid button accounts for horizontal margins with an explicit width. The resize handle adds touch-none to keep touch drags active.
Threshold width preservation
src/components/Sidebar/sidebarWidth.js, src/components/Sidebar/sidebarWidth.test.js
resolveCrossingWidth preserves a width selected below the threshold when crossing upward. A test verifies the selected width and lastExpandedWidth.

Priority: ⬇️ Low — Impact reflects low issue severity.

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to f1f4f

Solid sidebar buttons now fill the rail within their margins, touch resizing avoids browser scroll cancellation, and user-selected widths persist across responsive threshold changes. No current merge-blocking risk remains.

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Comment @coderabbitai help to get the list of available commands.

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