Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/36227-sidebar-resize-float-card.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(console): the left sidebar resizes by its right edge, the collapsed sidebar floats as a card, and a menu opened from the float no longer leaves it folded with the menu cut off

Clause-②: yes (widening) — one new `@object-ui/i18n` key (`sidebar.resize`) in all 11 locales; no spec, schema, server or published export change
Metadata-protocol: none

- **Resize** (`@object-ui/app-shell`): from 768 px up, the docked sidebar's right edge drags it between 200 and 350 px; a double-click comes back to 256; ← → move it 16 px, Home and End to either end. The width is kept in this browser (`console.sidebar.width`) and the menu floating over a collapsed sidebar takes it too. A phone's drawer keeps its own width.
- **The float is a card:** 8 px off the window's left, top and bottom edges, with rounded corners, a border and a shadow; the page under it is not dimmed or moved. Resting the pointer at the window's left edge still floats it and moving away still folds it.
- **A menu opened from the float keeps it out:** pressing the app name (or the account, or an entry's `…`) while the float was still sliding in under the pointer opened the menu and folded the float a moment later, leaving the menu cut off at the window's left edge. A press in the float now stops the fold's clock, and the fold does not happen while a menu or dialog is open, or while the pointer is on the float.
119 changes: 119 additions & 0 deletions ui/packages/app-shell/src/layout/SidebarWidthHandle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* SidebarWidthHandle — the docked console sidebar's right edge, which resizes
* it (objectstack#36227, as Attio): dragged with the pointer between
* {@link CONSOLE_SIDEBAR_MIN_WIDTH} and {@link CONSOLE_SIDEBAR_MAX_WIDTH}, or
* moved with ← → (Home / End to either end). A double-click comes back to
* {@link CONSOLE_EXPANDED_SIDEBAR_WIDTH}. `onPreview` follows a drag;
* `onCommit` keeps the width once it ends. The same shape as the record page's
* details-column handle (`RecordPageColumns` in `@object-ui/plugin-detail`).
*/

import * as React from 'react';
import { useObjectTranslation } from '@object-ui/i18n';
import {
CONSOLE_EXPANDED_SIDEBAR_WIDTH,
CONSOLE_SIDEBAR_MAX_WIDTH,
CONSOLE_SIDEBAR_MIN_WIDTH,
clampConsoleSidebarWidth,
} from './consoleSidebarRail.js';

/** How far one arrow-key press moves the sidebar's edge, in CSS pixels. */
export const SIDEBAR_WIDTH_KEY_STEP = 16;

export interface SidebarWidthHandleProps {
/** The width the sidebar has now, a drag's included. */
width: number;
/** A drag in progress: its width, or `null` once it ends. */
onPreview: (width: number | null) => void;
/** Keep this width. */
onCommit: (width: number) => void;
}

export function SidebarWidthHandle({ width, onPreview, onCommit }: SidebarWidthHandleProps) {
const { t } = useObjectTranslation();
const drag = React.useRef<{ x: number; width: number; last: number } | null>(null);

const end = (commit: boolean) => {
const start = drag.current;
drag.current = null;
document.body.style.removeProperty('cursor');
document.body.style.removeProperty('user-select');
onPreview(null);
if (commit && start && start.last !== start.width) onCommit(start.last);
};

// The handle can go away mid-drag: ⌘/Ctrl+B folds the sidebar, or the window
// narrows past 768 px, while the edge is still held. The drag then ends as a
// cancel: the page is selectable again and the sidebar goes back to the
// width it had when the drag began, the way a pointer-cancel ends it.
const previewRef = React.useRef(onPreview);
React.useEffect(() => {
previewRef.current = onPreview;
});
React.useEffect(
() => () => {
if (!drag.current) return;
drag.current = null;
document.body.style.removeProperty('cursor');
document.body.style.removeProperty('user-select');
previewRef.current(null);
},
[],
);

return (
<div
role="separator"
aria-orientation="vertical"
aria-label={t('sidebar.resize', { defaultValue: 'Resize sidebar' })}
aria-valuenow={width}
aria-valuemin={CONSOLE_SIDEBAR_MIN_WIDTH}
aria-valuemax={CONSOLE_SIDEBAR_MAX_WIDTH}
tabIndex={0}
data-testid="console-sidebar-resize"
className="group/resize absolute inset-y-0 -right-1 z-20 flex w-2 cursor-col-resize touch-none justify-center focus-visible:outline-none"
onPointerDown={(event) => {
if (event.button !== 0) return;
event.preventDefault();
event.currentTarget.setPointerCapture?.(event.pointerId);
drag.current = { x: event.clientX, width, last: width };
document.body.style.setProperty('cursor', 'col-resize');
document.body.style.setProperty('user-select', 'none');
}}
onPointerMove={(event) => {
const start = drag.current;
if (!start) return;
start.last = clampConsoleSidebarWidth(start.width + event.clientX - start.x);
onPreview(start.last);
}}
onPointerUp={(event) => {
event.currentTarget.releasePointerCapture?.(event.pointerId);
end(true);
}}
onPointerCancel={() => end(false)}
onDoubleClick={() => {
end(false);
onCommit(CONSOLE_EXPANDED_SIDEBAR_WIDTH);
}}
onKeyDown={(event) => {
const next =
event.key === 'ArrowLeft' ? width - SIDEBAR_WIDTH_KEY_STEP
: event.key === 'ArrowRight' ? width + SIDEBAR_WIDTH_KEY_STEP
: event.key === 'Home' ? CONSOLE_SIDEBAR_MIN_WIDTH
: event.key === 'End' ? CONSOLE_SIDEBAR_MAX_WIDTH
: null;
if (next === null) return;
event.preventDefault();
const clamped = clampConsoleSidebarWidth(next);
if (clamped !== width) onCommit(clamped);
}}
>
<span
aria-hidden="true"
className="h-full w-0.5 bg-transparent transition-colors group-hover/resize:bg-sidebar-border group-active/resize:bg-primary/60 group-focus-visible/resize:bg-ring"
/>
</div>
);
}
30 changes: 28 additions & 2 deletions ui/packages/app-shell/src/layout/UnifiedSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ import { InboxBell } from './InboxBell.js';
import { AccountMenu } from './AccountMenu.js';
import { useCommandPalette, useCommandPaletteProviderMounted } from '../context/CommandPaletteProvider.js';
import { confirmUnsavedLeave } from '../chrome/unsavedEdits.js';
import { SIDEBAR_EDGE_ZONE, useConsoleSidebarRail, useConsoleSidebarRailPanel } from './consoleSidebarRail.js';
import {
CONSOLE_EXPANDED_SIDEBAR_WIDTH,
CONSOLE_SIDEBAR_WIDTH_PREFERENCE,
SIDEBAR_EDGE_ZONE,
SIDEBAR_RESIZING_FRAME,
useConsoleSidebarRail,
useConsoleSidebarRailPanel,
} from './consoleSidebarRail.js';
import { SidebarWidthHandle } from './SidebarWidthHandle.js';
import { useWorkspacePreference } from '../utils/workspacePreference.js';
import { SidebarItemMenu, sidebarItemDesignPath, favoriteDesignPath } from './SidebarItemMenu.js';
import { SortableFavoriteRows, type FavoriteRowDragProps } from './SortableFavoriteRows.js';
import { favoriteAppSegment } from './listViewFavorites.js';
Expand Down Expand Up @@ -214,6 +223,16 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false
const rail = useConsoleSidebarRail({ enabled: railOverlay });
const sidebarRef = React.useRef<HTMLDivElement | null>(null);
const railPanel = useConsoleSidebarRailPanel(rail, sidebarRef);
// objectstack#36227 — from 768 px up the reader drags the docked sidebar's
// right edge to resize it; this browser keeps the width, and the menu
// floating over a collapsed sidebar takes it too.
const [keptWidth, setKeptWidth] = useWorkspacePreference(
CONSOLE_SIDEBAR_WIDTH_PREFERENCE,
'user',
CONSOLE_EXPANDED_SIDEBAR_WIDTH,
);
const [dragWidth, setDragWidth] = React.useState<number | null>(null);
const sidebarWidth = dragWidth ?? keptWidth;
// objectstack#36112 — from 768 px up the console draws no top bar: the
// sidebar starts at the top of the window and carries the app menu, the
// search and the bell in its head, and the account at its foot.
Expand Down Expand Up @@ -743,7 +762,11 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false
);

return (
<div data-testid="console-sidebar-frame" className={railPanel.frameClassName}>
<div
data-testid="console-sidebar-frame"
className={cn(railPanel.frameClassName, dragWidth !== null && SIDEBAR_RESIZING_FRAME)}
style={rail.desktop ? ({ '--sidebar-width': `${sidebarWidth}px` } as React.CSSProperties) : undefined}
>
<Sidebar
ref={sidebarRef}
collapsible={railPanel.collapsible}
Expand Down Expand Up @@ -952,6 +975,9 @@ export function UnifiedSidebar({ activeAppName, onAppChange, railOverlay = false
{/* No footer trigger: from 768 px up the trigger is the head's collapse
button and, while collapsed, the page header's expand button; on a
phone the app bar's left slot holds it. */}
{railPanel.docked && (
<SidebarWidthHandle width={sidebarWidth} onPreview={setDragWidth} onCommit={setKeptWidth} />
)}
</Sidebar>
{/* objectstack#35062 — the window's left edge while the sidebar is
hidden: resting the pointer on it, or a press, floats the menu. For
Expand Down
Loading
Loading