The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Unify resizing with ResizeHandle (#27083)
Raphaël Bosid7493d4f4822
diff --git a/packages/twenty-docs/snippets/ui/generated/layout/resize-handle.mdx b/packages/twenty-docs/snippets/ui/generated/layout/resize-handle.mdxindex 9b55c26dbf2..bd2a2eeca0b 100644--- a/packages/twenty-docs/snippets/ui/generated/layout/resize-handle.mdx+++ b/packages/twenty-docs/snippets/ui/generated/layout/resize-handle.mdx@@ -11,18 +11,30 @@* npx nx generate:ui twenty-docs*/}-<ParamField body="axis" type=""x" | "y"" default="y">- Pointer movement axis: `y` for height or `x` for width.+<ParamField body="axis" type=""x" | "y"" default="y without edge">+ Pointer movement axis without `edge`: `y` for height or `x` for width.</ParamField><ParamField body="defaultValue" type="number | (readonly string[] & number)" default="150">Initial size when the handle owns its state.</ParamField>+<ParamField body="direction" type=""normal" | "reverse"">+ Physical increasing direction. Omit to follow the horizontal text direction; use `normal` or `reverse` for a fixed physical edge.+</ParamField>+<ParamField body="disabled" type="boolean" default="false">Disables resizing and removes the handle from the tab order.</ParamField>+<ParamField body="dragThreshold" type="number" default="5 with edge; 0 otherwise">+ Physical pointer distance required before resizing starts. Movement below the threshold remains a click. Defaults to 5 with `edge` and 0 otherwise.+</ParamField>++<ParamField body="edge" type=""bottom" | "left" | "right" | "top"">+ Physical panel edge. Determines the movement axis and increasing direction, independently of text direction.+</ParamField>+<ParamField body="max" type="number" default="500">Maximum allowed size.</ParamField>@@ -31,8 +43,28 @@Minimum allowed size.</ParamField>+<ParamField body="onActivate" type="(() => void)">+ Called for a click without dragging, Enter, or Space.+</ParamField>++<ParamField body="onResizeEnd" type="((details: { cancelled: boolean; value: number; }) => void)">+ Called after a started drag ends, with its final value and whether it was cancelled. Cancellation restores the starting value within the current bounds.+</ParamField>++<ParamField body="onResizeStart" type="((value: number) => void)">+ Called once with the first bounded drag value after the threshold is crossed.+</ParamField>+<ParamField body="onValueChange" type="((value: number) => void)">- Called with the bounded size after pointer or keyboard interaction.+ Called with the bounded size during pointer or keyboard interaction and with the restored value on cancellation.+</ParamField>++<ParamField body="onValueCommitted" type="((value: number) => void)">+ Called with the final size after a successful drag or an effective keyboard size change. Cancellation does not commit.+</ParamField>++<ParamField body="placement" type=""edge" | "gap" | "inline"" default="edge with edge; inline otherwise">+ Layout mode: `inline` stays in normal flow, `edge` positions the handle on the panel edge, and `gap` sits between panels. Defaults to `edge` when `edge` is set and `inline` otherwise.</ParamField><ParamField body="render" type="ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>">@@ -42,10 +74,14 @@Accepts a `ReactElement` or a function that returns the element to render.</ParamField>+<ParamField body="scale" type="number | (() => number)" default="1">+ Pointer scale or resolver sampled at pointer down. Movement is divided by this positive scale; keyboard steps are unchanged.+</ParamField>+<ParamField body="step" type="number" default="10">Keyboard arrow increment. Pointer movement uses the pixel delta.</ParamField><ParamField body="value" type="number">- Controlled size. Apply the value to the element being resized.+ Current controlled size. Update it in `onValueChange` and apply it to the element being resized.</ParamField>diff --git a/packages/twenty-docs/ui/primitives/layout/resize-handle.mdx b/packages/twenty-docs/ui/primitives/layout/resize-handle.mdxindex 7efa823c924..d027ec617f3 100644--- a/packages/twenty-docs/ui/primitives/layout/resize-handle.mdx+++ b/packages/twenty-docs/ui/primitives/layout/resize-handle.mdx@@ -16,7 +16,7 @@ import ResizeHandleReference from '/snippets/ui/generated/layout/resize-handle.m## Usage-Use `axis="y"` for height or `axis="x"` for width. Give the handle a specific accessible name and use `aria-controls` to identify the panel.+Use `edge` for a panel boundary, or `axis="y"` for inline height resizing and `axis="x"` for inline width resizing. Give the handle a specific accessible name and use `aria-controls` to identify the panel.## Uncontrolled state@@ -80,19 +80,90 @@ export const ResizableNotes = () => {};```-The application owns the value and can update it from other controls. Keep `value` and `defaultValue` separate and retain the same ownership mode throughout the component's lifetime.+The application owns the value and can update it from other controls. Reflect live changes in `value`; use `onValueCommitted` to save the final size. Keep `value` and `defaultValue` separate and retain the same ownership mode throughout the component's lifetime.++## Panel edges and gaps++`edge="left"`, `"right"`, `"top"` or `"bottom"` determines both the axis and the physical increasing direction. Leftward movement grows a left edge, upward movement grows a top edge, and the opposite applies to right and bottom edges. This behavior stays the same in right-to-left content. Use either `edge` or `axis` and `direction`.++With `edge`, placement defaults to `"edge"`. Put the handle inside a panel with `position: 'relative'` to position it along that boundary. `placement="inline"` keeps it in normal flow. Use `placement="gap"` between sibling panels and set its width or height through `style` when the layout needs a gap. Gap handles have no visible grip by default.++```tsx+import { useId, useState } from 'react';+import { ResizeHandle } from 'twenty-ui/primitives/layout';+import { Card } from 'twenty-ui/primitives/surfaces';+import { Text } from 'twenty-ui/primitives/typography';++export const ResizableDetails = ({+ saveWidth,+}: {+ saveWidth: (value: number) => void;+}) => {+ const detailsId = useId();+ const [width, setWidth] = useState(380);++ return (+ <div style={{ display: 'flex', height: 200 }}>+ <Card.Root style={{ flex: 1 }}>+ <Text>Activity</Text>+ </Card.Root>+ <ResizeHandle+ edge="left"+ placement="gap"+ value={width}+ onValueChange={setWidth}+ onValueCommitted={saveWidth}+ min={280}+ max={800}+ style={{ width: 12 }}+ aria-label="Resize details"+ aria-controls={detailsId}+ />+ <Card.Root id={detailsId} style={{ width }}>+ <Text>Details</Text>+ </Card.Root>+ </div>+ );+};+```++<StoryEmbed+ storyId="ui-layout-resizehandle-panels--documentation"+ title="ResizeHandle panel edge example"+/>++<StoryEmbed+ storyId="ui-layout-resizehandle-panels--gap"+ title="ResizeHandle panel gap example"+/>++The application owns the layout, saved size, collapse state and focus destination when collapsing removes the handle. Use `onActivate` for an optional collapse action.## Keyboard and boundsFor `axis="y"`, Down increases the size and Up decreases it. For `axis="x"`, Right increases and Left decreases in left-to-right content; the directions reverse under [DirectionProvider](/ui/primitives/layout/direction-provider) with `direction="rtl"`.-Arrow keys use `step`, which defaults to `10`. Home moves to `min`, and End moves to `max`. Pointer dragging uses the pixel movement and is not snapped to `step`. Both interactions stay within the bounds. `disabled` prevents resizing and removes the handle from the tab order.+Arrow keys use `step`, which defaults to `10`. Home moves to `min`, and End moves to `max`. Keys pressed with Alt, Control or Meta are ignored. Pointer dragging uses the pixel movement and is not snapped to `step`. Both interactions stay within the bounds. Pointer presses do not move focus; keyboard users reach the handle with Tab. `disabled` prevents resizing and removes the handle from the tab order.The separator orientation describes the dividing edge: horizontal for height resizing and vertical for width resizing.+## Physical directions and zoom++Set `direction="normal"` or `direction="reverse"` when increasing size must follow a fixed physical direction, regardless of text direction. Normal increases with rightward or downward movement. Reverse increases with leftward or upward movement. Omit `direction` to retain the text-direction behavior described above.++`scale` accepts a positive zoom factor or a function returning one. The handle samples it at pointer down and divides pointer movement by that value. Keyboard steps remain unchanged.++## Gesture lifecycle++`onValueChange` reports live values. `onValueCommitted` reports the final value after a successful pointer drag or an effective keyboard change. Home, End and arrow keys commit immediately when they change the size.++`onResizeStart` receives the first bounded candidate after the pointer passes `dragThreshold`. The threshold defaults to `5` with `edge` and `0` otherwise, measured in physical pixels. `onResizeEnd` receives `{ cancelled, value }` for a started drag. Escape, pointer cancellation, lost pointer capture and unmounting cancel the gesture without committing; disabling the handle cancels it on its next pointer event. Cancellation calls `onValueChange` with the starting value, clamped to the current bounds. `onResizeEnd` receives that restored value.++Supply `onActivate` to handle a click without dragging, Enter or Space. Crossing the threshold prevents the following pointer click from activating, even when the pointer returns to its starting position. Native event handlers can prevent the default interaction.+## Custom handle-`children` replaces the visible grip; it does not replace the separator behavior. `render` can replace the root element. Custom wrappers must [forward the supplied props and ref](/ui/primitives/overview#custom-components) so focus, pointer capture, keyboard handlers, and accessibility attributes reach the same element.+`children` replaces the visible grip, and `children={null}` hides it; it does not replace the separator behavior. `render` can replace the root element. Custom wrappers must [forward the supplied props and ref](/ui/primitives/overview#custom-components) so focus, pointer capture, keyboard handlers, and accessibility attributes reach the same element.## Propsdiff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsxindex e6430d60a3f..39c08aaac57 100644--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx@@ -19,6 +19,7 @@ import { numberStepperSandboxFailureTest } from '@/__stories__/twenty-ui-galleryimport { settingsRowTest } from '@/__stories__/twenty-ui-gallery/utils/settingsRowTest';import { layoutTest } from '@/__stories__/twenty-ui-gallery/utils/layoutTest';import { listItemTest } from '@/__stories__/twenty-ui-gallery/utils/listItemTest';+import { resizeHandlePanelTest } from '@/__stories__/twenty-ui-gallery/utils/resizeHandlePanelTest';import { pickerListItemsTest } from '@/__stories__/twenty-ui-gallery/utils/pickerListItemsTest';import { iconButtonElevatedTest } from '@/__stories__/twenty-ui-gallery/utils/iconButtonElevatedTest';import { buttonControlsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonControlsTest';@@ -179,6 +180,18 @@ export const LayoutPreact: Story = createGalleryStory({play: layoutTest,});+export const ResizeHandleReact: Story = createGalleryStory({+ frontComponentBundleName: 'twenty-ui-resize-handle',+ runtime: 'react',+ play: resizeHandlePanelTest,+});++export const ResizeHandlePreact: Story = createGalleryStory({+ frontComponentBundleName: 'twenty-ui-resize-handle',+ runtime: 'preact',+ play: resizeHandlePanelTest,+});+export const NavigationReact: Story = createGalleryStory({frontComponentBundleName: 'twenty-ui-navigation-gallery',runtime: 'react',diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-resize-handle.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-resize-handle.front-component.tsxnew file mode 100644index 00000000000..309e5fd06cd--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-resize-handle.front-component.tsx@@ -0,0 +1,74 @@+import { useId, useState } from 'react';+import { defineFrontComponent } from 'twenty-sdk/define';+import { ResizeHandle } from 'twenty-ui/primitives/layout';+import { Card } from 'twenty-ui/primitives/surfaces';+import { Text } from 'twenty-ui/primitives/typography';++import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';++const ResizeHandleExample = () => {+ const edgeRegionId = useId();+ const gapRegionId = useId();+ const [edgeSize, setEdgeSize] = useState(160);+ const [committedEdgeSize, setCommittedEdgeSize] = useState(160);+ const [gapSize, setGapSize] = useState(100);+ const [committedGapSize, setCommittedGapSize] = useState(100);+ const [collapseCount, setCollapseCount] = useState(0);+ const [edgeClickCount, setEdgeClickCount] = useState(0);+ const [lastResizeResult, setLastResizeResult] = useState('Ready');++ return (+ <TwentyUiGalleryCard title="Panel resize handle interactions">+ <Card.Root+ id={edgeRegionId}+ style={{ width: edgeSize, height: 100, position: 'relative' }}+ >+ <Text>Edge size: {edgeSize}</Text>+ <ResizeHandle+ aria-label="Resize edge panel"+ aria-controls={edgeRegionId}+ edge="left"+ value={edgeSize}+ min={100}+ max={240}+ onValueChange={setEdgeSize}+ onValueCommitted={setCommittedEdgeSize}+ onResizeStart={() => setLastResizeResult('Resizing')}+ onResizeEnd={({ cancelled }) =>+ setLastResizeResult(cancelled ? 'Cancelled' : 'Finished')+ }+ onActivate={() => setCollapseCount((count) => count + 1)}+ onClick={() => setEdgeClickCount((count) => count + 1)}+ />+ </Card.Root>+ <Text>Committed edge: {committedEdgeSize}</Text>+ <Text>Collapse count: {collapseCount}</Text>+ <Text>Edge clicks: {edgeClickCount}</Text>+ <Text>Resize result: {lastResizeResult}</Text>+ <ResizeHandle+ aria-label="Resize gap panel"+ aria-controls={gapRegionId}+ placement="gap"+ style={{ height: 16 }}+ edge="top"+ value={gapSize}+ min={60}+ max={180}+ scale={2}+ onValueChange={setGapSize}+ onValueCommitted={setCommittedGapSize}+ />+ <Card.Root id={gapRegionId} style={{ height: gapSize }}>+ <Text>Gap size: {gapSize}</Text>+ </Card.Root>+ <Text>Committed gap: {committedGapSize}</Text>+ </TwentyUiGalleryCard>+ );+};++export default defineFrontComponent({+ universalIdentifier: '63822535-44c3-4d2b-b0c2-5351a355ba53',+ name: 'twenty-ui-resize-handle',+ description: 'Panel resize handle sizing and activation in the sandbox',+ component: ResizeHandleExample,+});diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandlePanelTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandlePanelTest.tsnew file mode 100644index 00000000000..6f7cebdd188--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandlePanelTest.ts@@ -0,0 +1,130 @@+import { expect, fireEvent, userEvent, waitFor, within } from 'storybook/test';++import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';+import { withMockPointerCapture } from '@/__stories__/twenty-ui-gallery/utils/withMockPointerCapture';++export const resizeHandlePanelTest: TwentyUiGalleryPlayFunction = async ({+ canvasElement,+}) => {+ const canvas = within(canvasElement);+ await expectFrontComponentMounted(canvas);+ const edge = canvas.getByRole('separator', { name: 'Resize edge panel' });+ const gap = canvas.getByRole('separator', { name: 'Resize gap panel' });++ await withMockPointerCapture({+ handles: [edge, gap],+ run: async () => {+ edge.focus();+ await expect(edge).toHaveFocus();+ await userEvent.keyboard('{ArrowLeft}');+ await waitFor(() => {+ expect(edge).toHaveAttribute('aria-valuenow', '170');+ expect(canvas.getByText('Committed edge: 170')).toBeVisible();+ });+ await userEvent.keyboard('{Home}');+ await waitFor(() => expect(edge).toHaveAttribute('aria-valuenow', '100'));+ await userEvent.keyboard('{End}');+ await waitFor(() => expect(edge).toHaveAttribute('aria-valuenow', '240'));+ await userEvent.keyboard('{Enter}');+ await expect(await canvas.findByText('Collapse count: 1')).toBeVisible();++ await fireEvent.pointerDown(edge, {+ pointerId: 1,+ button: 0,+ clientX: 100,+ });+ await fireEvent.pointerMove(edge, { pointerId: 1, clientX: 130 });+ await waitFor(() => {+ expect(edge).toHaveAttribute('aria-valuenow', '210');+ expect(canvas.getByText('Edge size: 210')).toBeVisible();+ expect(canvas.getByText('Resize result: Resizing')).toBeVisible();+ expect(canvas.getByText('Committed edge: 240')).toBeVisible();+ expect(gap).toHaveAttribute('aria-valuenow', '100');+ });+ await fireEvent.pointerUp(edge, { pointerId: 1, clientX: 130 });+ await expect(+ await canvas.findByText('Resize result: Finished'),+ ).toBeVisible();+ await fireEvent.click(edge, { detail: 1 });+ await expect(await canvas.findByText('Edge clicks: 1')).toBeVisible();+ await waitFor(() => {+ expect(canvas.getByText('Committed edge: 210')).toBeVisible();+ expect(canvas.getByText('Resize result: Finished')).toBeVisible();+ expect(canvas.getByText('Collapse count: 1')).toBeVisible();+ });++ await fireEvent.pointerDown(edge, {+ pointerId: 2,+ button: 0,+ clientX: 100,+ });+ await fireEvent.pointerMove(edge, { pointerId: 2, clientX: 500 });+ await waitFor(() => expect(edge).toHaveAttribute('aria-valuenow', '100'));+ await fireEvent.pointerCancel(edge, { pointerId: 2 });+ await waitFor(() => {+ expect(edge).toHaveAttribute('aria-valuenow', '210');+ expect(canvas.getByText('Committed edge: 210')).toBeVisible();+ expect(canvas.getByText('Resize result: Cancelled')).toBeVisible();+ });+ await fireEvent.pointerMove(edge, { pointerId: 2, clientX: 600 });+ await expect(edge).toHaveAttribute('aria-valuenow', '210');+ await fireEvent.click(edge, { detail: 0 });+ await expect(await canvas.findByText('Collapse count: 2')).toBeVisible();++ await fireEvent.pointerDown(edge, {+ pointerId: 5,+ button: 0,+ clientX: 100,+ });+ await fireEvent.pointerMove(edge, { pointerId: 5, clientX: 130 });+ await waitFor(() => {+ expect(edge).toHaveAttribute('aria-valuenow', '180');+ expect(canvas.getByText('Resize result: Resizing')).toBeVisible();+ });+ await userEvent.keyboard('{Escape}');+ await waitFor(() => {+ expect(edge).toHaveAttribute('aria-valuenow', '210');+ expect(canvas.getByText('Committed edge: 210')).toBeVisible();+ expect(canvas.getByText('Resize result: Cancelled')).toBeVisible();+ });+ await fireEvent.pointerUp(edge, { pointerId: 5, clientX: 130 });++ await fireEvent.pointerDown(edge, {+ pointerId: 3,+ button: 0,+ clientX: 100,+ });+ await fireEvent.pointerUp(edge, { pointerId: 3, clientX: 100 });+ await fireEvent.click(edge, { detail: 1 });+ await expect(await canvas.findByText('Collapse count: 3')).toBeVisible();+ await expect(edge).toHaveAttribute('aria-valuenow', '210');+ await expect(canvas.getByText('Committed edge: 210')).toBeVisible();+ await expect(canvas.getByText('Resize result: Cancelled')).toBeVisible();++ await userEvent.click(gap);+ await expect(gap).not.toHaveFocus();+ gap.focus();+ await userEvent.keyboard('{ArrowUp}');+ await waitFor(() => {+ expect(gap).toHaveAttribute('aria-valuenow', '110');+ expect(canvas.getByText('Committed gap: 110')).toBeVisible();+ });+ await fireEvent.pointerDown(gap, {+ pointerId: 4,+ button: 0,+ clientY: 100,+ });+ await fireEvent.pointerMove(gap, { pointerId: 4, clientY: 60 });+ await waitFor(() => {+ expect(gap).toHaveAttribute('aria-valuenow', '130');+ expect(canvas.getByText('Committed gap: 110')).toBeVisible();+ expect(edge).toHaveAttribute('aria-valuenow', '210');+ });+ await fireEvent.pointerUp(gap, { pointerId: 4, clientY: 60 });+ await expect(await canvas.findByText('Committed gap: 130')).toBeVisible();+ await expect(errorHandler).not.toHaveBeenCalled();+ },+ });+};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandleTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandleTest.tsindex c5aca48f7de..0d35fa86b36 100644--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandleTest.ts+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/resizeHandleTest.ts@@ -1,15 +1,9 @@-import {- expect,- fireEvent,- spyOn,- userEvent,- waitFor,- within,-} from 'storybook/test';+import { expect, fireEvent, userEvent, waitFor, within } from 'storybook/test';import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/galleryRenderTests';+import { withMockPointerCapture } from '@/__stories__/twenty-ui-gallery/utils/withMockPointerCapture';export const resizeHandleTest: TwentyUiGalleryPlayFunction = async (context,@@ -31,61 +25,54 @@ export const resizeHandleTest: TwentyUiGalleryPlayFunction = async (await userEvent.keyboard('{End}');await waitFor(() => expect(handle).toHaveAttribute('aria-valuenow', '200'));- const capturedPointers = new Set<number>();- const setPointerCapture = spyOn(- handle,- 'setPointerCapture',- ).mockImplementation((pointerId) => {- capturedPointers.add(pointerId);- });- const hasPointerCapture = spyOn(- handle,- 'hasPointerCapture',- ).mockImplementation((pointerId) => capturedPointers.has(pointerId));- const releasePointerCapture = spyOn(- handle,- 'releasePointerCapture',- ).mockImplementation((pointerId) => {- capturedPointers.delete(pointerId);- });const pointer = userEvent.setup();- try {- for (const endEvent of [- 'pointerUp',- 'pointerCancel',- 'lostPointerCapture',- ] as const) {- handle.blur();- await pointer.pointer({- target: handle.firstElementChild!,- keys: '[MouseLeft>]',- coords: { y: 100 },- });- await expect(setPointerCapture).toHaveBeenLastCalledWith(1);- await expect(handle).toHaveFocus();- await pointer.pointer({ target: handle, coords: { y: 80 } });- await waitFor(() => {- expect(handle).toHaveAttribute('aria-valuenow', '180');- expect(canvas.getByText('180 pixels')).toBeVisible();- });- await fireEvent[endEvent](handle, { pointerId: 1 });- await pointer.pointer({ target: handle, coords: { y: 0 } });- await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });- await userEvent.keyboard('{ArrowDown}');- await waitFor(() =>- expect(handle).toHaveAttribute('aria-valuenow', '190'),- );- await userEvent.keyboard('{End}');- await waitFor(() =>- expect(handle).toHaveAttribute('aria-valuenow', '200'),- );- }- await expect(releasePointerCapture).toHaveBeenCalledWith(1);- await expect(errorHandler).not.toHaveBeenCalled();- } finally {- setPointerCapture.mockRestore();- hasPointerCapture.mockRestore();- releasePointerCapture.mockRestore();- }+ await withMockPointerCapture({+ handles: [handle],+ run: async () => {+ for (const endEvent of [+ 'pointerUp',+ 'pointerCancel',+ 'lostPointerCapture',+ ] as const) {+ handle.blur();+ await pointer.pointer({+ target: handle.firstElementChild!,+ keys: '[MouseLeft>]',+ coords: { y: 100 },+ });+ await expect(handle.setPointerCapture).toHaveBeenLastCalledWith(1);+ await expect(handle).not.toHaveFocus();+ await pointer.pointer({ target: handle, coords: { y: 80 } });+ await waitFor(() => {+ expect(handle).toHaveAttribute('aria-valuenow', '180');+ expect(canvas.getByText('180 pixels')).toBeVisible();+ });+ await fireEvent[endEvent](handle, { pointerId: 1, clientY: 80 });+ const finalValue = endEvent === 'pointerUp' ? '180' : '200';+ const valueAfterKeyboardStep = endEvent === 'pointerUp' ? '190' : '200';++ await waitFor(() => {+ expect(handle).toHaveAttribute('aria-valuenow', finalValue);+ expect(canvas.getByText(`${finalValue} pixels`)).toBeVisible();+ });+ await pointer.pointer({ target: handle, coords: { y: 0 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ handle.focus();+ await userEvent.keyboard('{ArrowDown}');+ await waitFor(() =>+ expect(handle).toHaveAttribute(+ 'aria-valuenow',+ valueAfterKeyboardStep,+ ),+ );+ await userEvent.keyboard('{End}');+ await waitFor(() =>+ expect(handle).toHaveAttribute('aria-valuenow', '200'),+ );+ }+ await expect(handle.releasePointerCapture).toHaveBeenCalledWith(1);+ await expect(errorHandler).not.toHaveBeenCalled();+ },+ });};diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withMockPointerCapture.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withMockPointerCapture.tsnew file mode 100644index 00000000000..4c0dc97c3c3--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/withMockPointerCapture.ts@@ -0,0 +1,43 @@+import { spyOn } from 'storybook/test';++type WithMockPointerCaptureArgs = {+ handles: HTMLElement[];+ run: () => Promise<void>;+};++export const withMockPointerCapture = async ({+ handles,+ run,+}: WithMockPointerCaptureArgs) => {+ const captureMocks: { mockRestore: () => void }[] = [];++ try {+ for (const handle of handles) {+ const capturedPointers = new Set<number>();++ captureMocks.push(+ spyOn(handle, 'setPointerCapture').mockImplementation((pointerId) => {+ capturedPointers.add(pointerId);+ }),+ );+ captureMocks.push(+ spyOn(handle, 'hasPointerCapture').mockImplementation((pointerId) =>+ capturedPointers.has(pointerId),+ ),+ );+ captureMocks.push(+ spyOn(handle, 'releasePointerCapture').mockImplementation(+ (pointerId) => {+ capturedPointers.delete(pointerId);+ },+ ),+ );+ }++ await run();+ } finally {+ for (const captureMock of captureMocks) {+ captureMock.mockRestore();+ }+ }+};diff --git a/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/createResizableSeparatorProps.test.ts b/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/createResizableSeparatorProps.test.tsindex c32f74f621a..22185529b04 100644--- a/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/createResizableSeparatorProps.test.ts+++ b/packages/twenty-front-component-renderer/src/host/elements/utils/__tests__/createResizableSeparatorProps.test.ts@@ -3,8 +3,13 @@ import { type PointerEvent } from 'react';import { createResizableSeparatorProps } from '../createResizableSeparatorProps';type SeparatorHandlers = Record<- 'onPointerDown' | 'onPointerUp' | 'onPointerCancel' | 'onLostPointerCapture',- (event: PointerEvent<HTMLElement>) => void+ | 'onMouseDown'+ | 'onPointerDown'+ | 'onPointerUp'+ | 'onPointerCancel'+ | 'onLostPointerCapture'+ | 'onKeyDown',+ (event: unknown) => void>;const createSeparatorElement = () => {@@ -35,7 +40,7 @@ const createPointerEvent = (preventDefault: jest.fn(),}) as unknown as PointerEvent<HTMLElement>;-const createSeparatorHandlers = () => {+const createSeparatorHandlers = (remoteProps: Record<string, unknown> = {}) => {const remotePointerCancel = jest.fn();const handlers = createResizableSeparatorProps({role: 'separator',@@ -43,12 +48,17 @@ const createSeparatorHandlers = () => {onPointerDown: jest.fn(),onPointerUp: jest.fn(),onPointerCancel: remotePointerCancel,+ ...remoteProps,}) as SeparatorHandlers;return { handlers, remotePointerCancel };};describe('createResizableSeparatorProps', () => {+ afterEach(() => {+ document.body.replaceChildren();+ });+it('should not apply to elements that are not enabled value separators', () => {expect(createResizableSeparatorProps({@@ -112,4 +122,88 @@ describe('createResizableSeparatorProps', () => {expect(remotePointerCancel).toHaveBeenCalledTimes(1);});+ it('should keep focus where it is when the separator is pressed', () => {+ const onMouseDown = jest.fn();+ const { handlers } = createSeparatorHandlers({ onMouseDown });+ const event = { preventDefault: jest.fn() };++ handlers.onMouseDown(event);++ expect(event.preventDefault).toHaveBeenCalledTimes(1);+ expect(onMouseDown).toHaveBeenCalledWith(event);+ });++ it('should capture the pointer without focusing the separator', () => {+ const onPointerDown = jest.fn();+ const { handlers } = createSeparatorHandlers({ onPointerDown });+ const separator = createSeparatorElement();+ const event = createPointerEvent(separator);++ separator.tabIndex = 0;+ document.body.append(separator);+ handlers.onPointerDown(event);++ expect(separator.hasPointerCapture(1)).toBe(true);+ expect(event.preventDefault).not.toHaveBeenCalled();+ expect(document.activeElement).not.toBe(separator);+ expect(onPointerDown).toHaveBeenCalledWith(event);+ });++ it('should prevent the host default for separator keys without modifiers', () => {+ const onKeyDown = jest.fn();+ const { handlers } = createSeparatorHandlers({ onKeyDown });+ const createKeyDownEvent = (key: string, metaKey = false) => ({+ key,+ metaKey,+ altKey: false,+ ctrlKey: false,+ preventDefault: jest.fn(),+ stopPropagation: jest.fn(),+ });+ const spaceEvent = createKeyDownEvent(' ');+ const shortcutEvent = createKeyDownEvent('ArrowLeft', true);+ const enterEvent = createKeyDownEvent('Enter');++ for (const event of [spaceEvent, shortcutEvent, enterEvent]) {+ handlers.onKeyDown(event);+ }++ expect(spaceEvent.preventDefault).toHaveBeenCalledTimes(1);+ expect(spaceEvent.stopPropagation).toHaveBeenCalledTimes(1);+ expect(shortcutEvent.preventDefault).not.toHaveBeenCalled();+ expect(enterEvent.preventDefault).not.toHaveBeenCalled();+ expect(onKeyDown).toHaveBeenCalledTimes(3);+ });++ it('should cancel the remote drag on Escape while the pointer is captured', () => {+ const { handlers, remotePointerCancel } = createSeparatorHandlers();+ const separator = createSeparatorElement();+ const handleDocumentKeyDown = jest.fn();++ document.addEventListener('keydown', handleDocumentKeyDown);+ handlers.onPointerDown(createPointerEvent(separator));++ const escapeEvent = new KeyboardEvent('keydown', {+ key: 'Escape',+ bubbles: true,+ cancelable: true,+ });+ document.body.dispatchEvent(escapeEvent);++ expect(escapeEvent.defaultPrevented).toBe(true);+ expect(handleDocumentKeyDown).not.toHaveBeenCalled();+ expect(separator.hasPointerCapture(1)).toBe(false);+ expect(remotePointerCancel).toHaveBeenCalledWith({+ type: 'pointercancel',+ pointerId: 1,+ });++ document.body.dispatchEvent(+ new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),+ );++ expect(handleDocumentKeyDown).toHaveBeenCalledTimes(1);+ expect(remotePointerCancel).toHaveBeenCalledTimes(1);+ document.removeEventListener('keydown', handleDocumentKeyDown);+ });});diff --git a/packages/twenty-front-component-renderer/src/host/elements/utils/cancelSeparatorDragOnEscape.ts b/packages/twenty-front-component-renderer/src/host/elements/utils/cancelSeparatorDragOnEscape.tsnew file mode 100644index 00000000000..e2ca28e4769--- /dev/null+++ b/packages/twenty-front-component-renderer/src/host/elements/utils/cancelSeparatorDragOnEscape.ts@@ -0,0 +1,41 @@+import { isDefined } from 'twenty-shared/utils';++export const cancelSeparatorDragOnEscape = ({+ separator,+ pointerId,+ onCancel,+}: {+ separator: HTMLElement;+ pointerId: number;+ onCancel: () => void;+}) => {+ const ownerWindow = separator.ownerDocument.defaultView;++ if (!isDefined(ownerWindow)) {+ return;+ }++ const handleKeyDown = (event: KeyboardEvent) => {+ if (!separator.hasPointerCapture(pointerId)) {+ ownerWindow.removeEventListener('keydown', handleKeyDown, true);+ return;+ }++ if (event.key !== 'Escape') {+ return;+ }++ event.preventDefault();+ event.stopPropagation();+ ownerWindow.removeEventListener('keydown', handleKeyDown, true);+ separator.releasePointerCapture(pointerId);+ onCancel();+ };++ ownerWindow.addEventListener('keydown', handleKeyDown, true);+ separator.addEventListener(+ 'lostpointercapture',+ () => ownerWindow.removeEventListener('keydown', handleKeyDown, true),+ { once: true },+ );+};diff --git a/packages/twenty-front-component-renderer/src/host/elements/utils/createResizableSeparatorProps.ts b/packages/twenty-front-component-renderer/src/host/elements/utils/createResizableSeparatorProps.tsindex 1fd912b54cd..4f173722077 100644--- a/packages/twenty-front-component-renderer/src/host/elements/utils/createResizableSeparatorProps.ts+++ b/packages/twenty-front-component-renderer/src/host/elements/utils/createResizableSeparatorProps.ts@@ -1,7 +1,8 @@import { isFunction } from '@sniptt/guards';-import { type PointerEvent } from 'react';+import { type KeyboardEvent, type MouseEvent, type PointerEvent } from 'react';import { isDefined } from 'twenty-shared/utils';+import { cancelSeparatorDragOnEscape } from '@/host/elements/utils/cancelSeparatorDragOnEscape';import { createSeparatorPointerCaptureReleaseTracker } from '@/host/elements/utils/createSeparatorPointerCaptureReleaseTracker';const {@@ -12,9 +13,11 @@ const {export const createResizableSeparatorProps = (reactBindableProps: Record<string, unknown>,): Record<string, unknown> | undefined => {+ const remoteMouseDown = reactBindableProps.onMouseDown;const remotePointerDown = reactBindableProps.onPointerDown;const remotePointerUp = reactBindableProps.onPointerUp;const remotePointerCancel = reactBindableProps.onPointerCancel;+ const remoteKeyDown = reactBindableProps.onKeyDown;const isDisabled =reactBindableProps['aria-disabled'] === true ||reactBindableProps['aria-disabled'] === 'true';@@ -29,15 +32,30 @@ export const createResizableSeparatorProps = (}return {+ onMouseDown: (event: MouseEvent<HTMLElement>) => {+ event.preventDefault();+ if (isFunction(remoteMouseDown)) {+ remoteMouseDown(event);+ }+ },onPointerDown: (event: PointerEvent<HTMLElement>) => {if (event.button !== 0 || event.defaultPrevented) {return;}+ const { pointerId } = event;+consumePointerCaptureReleasedAtGestureEnd(event);- event.preventDefault();- event.currentTarget.focus();- event.currentTarget.setPointerCapture(event.pointerId);+ event.currentTarget.setPointerCapture(pointerId);+ cancelSeparatorDragOnEscape({+ separator: event.currentTarget,+ pointerId,+ onCancel: () => {+ if (isFunction(remotePointerCancel)) {+ remotePointerCancel({ type: 'pointercancel', pointerId });+ }+ },+ });remotePointerDown(event);},onPointerUp: (event: PointerEvent<HTMLElement>) => {@@ -61,5 +79,26 @@ export const createResizableSeparatorProps = (remotePointerCancel(event);}},+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => {+ const hasModifierKey = event.altKey || event.ctrlKey || event.metaKey;+ const isSeparatorKey = [+ ' ',+ 'ArrowUp',+ 'ArrowDown',+ 'ArrowLeft',+ 'ArrowRight',+ 'Home',+ 'End',+ ].includes(event.key);++ if (isSeparatorKey && !hasModifierKey) {+ event.preventDefault();+ event.stopPropagation();+ }++ if (isFunction(remoteKeyDown)) {+ remoteKeyDown(event);+ }+ },};};diff --git a/packages/twenty-front/.storybook/preview.tsx b/packages/twenty-front/.storybook/preview.tsxindex 85bee6e629c..577370a1eee 100644--- a/packages/twenty-front/.storybook/preview.tsx+++ b/packages/twenty-front/.storybook/preview.tsx@@ -32,7 +32,7 @@ import 'react-loading-skeleton/dist/skeleton.css';import 'twenty-ui/style.css';import 'twenty-ui/theme-light.css';import 'twenty-ui/theme-dark.css';-import { ThemeProvider } from 'twenty-ui/theme';+import { GRAY_SCALE_LIGHT, ThemeProvider } from 'twenty-ui/theme';// oxlint-disable-next-line no-restricted-importsimport { messages as enMessages } from '../src/locales/generated/en';@@ -41,8 +41,7 @@ i18n.activate(SOURCE_LOCALE);// oxlint-disable-next-line no-restricted-importsimport { ClickOutsideListenerContext } from '../src/modules/ui/utilities/pointer-event/contexts/ClickOutsideListenerContext';-const MOCK_IMAGE_SVG =- '<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192"><rect width="192" height="192" fill="#d9d9d9"/></svg>';+const MOCK_IMAGE_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192"><rect width="192" height="192" fill="${GRAY_SCALE_LIGHT.gray6}"/></svg>`;const respondWithMockImage = () =>new HttpResponse(MOCK_IMAGE_SVG, {diff --git a/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx b/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsxindex 47a186c67e3..7c409398f22 100644--- a/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx+++ b/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx@@ -3,7 +3,7 @@ import { motion } from 'framer-motion';import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';import { SKELETON_LOADER_HEIGHT_SIZES } from '@/activities/components/SkeletonLoader';-import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/layout/resizable-panel/constants/NavigationDrawerConstraints';+import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints';import { useIsMobile } from 'twenty-ui/utilities';import { MainNavigationDrawerItemsSkeletonLoader } from '~/loading/components/MainNavigationDrawerItemsSkeletonLoader';import { useTheme, themeCssVariables } from 'twenty-ui/theme';diff --git a/packages/twenty-front/src/loading/components/UserOrMetadataLoader.tsx b/packages/twenty-front/src/loading/components/UserOrMetadataLoader.tsxindex a4365570c3b..010b6567a2c 100644--- a/packages/twenty-front/src/loading/components/UserOrMetadataLoader.tsx+++ b/packages/twenty-front/src/loading/components/UserOrMetadataLoader.tsx@@ -1,6 +1,6 @@import { styled } from '@linaria/react';-import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/layout/resizable-panel/constants/NavigationDrawerConstraints';+import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints';import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme';import { LeftPanelSkeletonLoader } from '~/loading/components/LeftPanelSkeletonLoader';import { PageContentSkeletonLoader } from '~/loading/components/PageContentSkeletonLoader';diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsole.tsxindex 45cce307739..607b495764c 100644--- a/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx+++ b/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx@@ -2,10 +2,12 @@ import { formatShortcut } from 'twenty-ui/primitives/typography';import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';import { useReducedMotion } from 'framer-motion';+import { useStore } from 'jotai';import { type TransitionEvent, useSyncExternalStore, useState } from 'react';import { isDefined } from 'twenty-shared/utils';import { useToast } from 'twenty-ui/components/feedback';import { IconButton, LightIconButton } from 'twenty-ui/components/input';+import { ResizeHandle } from 'twenty-ui/primitives/layout';import {IconChevronDown,IconChevronUp,@@ -38,7 +40,6 @@ import { SettingsEnterpriseFeatureGateCard } from '@/settings/components/Settingimport { SETTINGS_CONTENT_MAX_WIDTH } from '@/settings/constants/SettingsContentMaxWidth';import { APP_HEADER_HEIGHT } from '@/ui/layout/constants/AppHeaderHeight';import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices';-import { ResizablePanelEdge } from '@/ui/layout/resizable-panel/components/ResizablePanelEdge';import { TabList } from '@/ui/layout/tab-list/components/TabList';import { TabListRoot } from '@/ui/layout/tab-list/components/TabListRoot';import { TAB_LIST_HEIGHT } from '@/ui/layout/tab-list/constants/TabListHeight';@@ -255,6 +256,7 @@ const StyledDetailPanelWrapper = styled.div<{export const LogConsole = () => {const { t } = useLingui();+ const store = useStore();const theme = useTheme();const { enqueueToast } = useToast();const shouldReduceMotion = useReducedMotion();@@ -285,6 +287,10 @@ export const LogConsole = () => {);const [isDetailPanelResizing, setIsDetailPanelResizing] = useState(false);const [isResizing, setIsResizing] = useState(false);+ const [liveHeight, setLiveHeight] = useState<number | null>(null);+ const [liveDetailPanelWidth, setLiveDetailPanelWidth] = useState<+ number | null+ >(null);const isOpen = logConsoleDisplayMode === 'open';const isFullScreen = isOpen && isLogConsoleFullScreen;@@ -330,7 +336,7 @@ export const LogConsole = () => {const appHeight = windowHeight / getUiZoom();const logConsoleResizeConstraints = {- min: 0,+ min: isOpen && !isResizing ? LOG_CONSOLE_HEIGHT_CONSTRAINTS.min : 0,max: Math.max(appHeight - APP_HEADER_HEIGHT - LOG_CONSOLE_MIN_PAGE_HEIGHT,LOG_CONSOLE_HEIGHT_CONSTRAINTS.min,@@ -418,12 +424,13 @@ export const LogConsole = () => {const handleResizeStart = (height: number) => {setIsResizing(true);- if (height > 0) {+ if (height > 0 && logConsoleDisplayMode === 'collapsed') {openLogConsole();}};const handleDetailPanelWidthChange = (width: number) => {+ setLiveDetailPanelWidth(null);document.documentElement.style.removeProperty(LOG_CONSOLE_DETAIL_PANEL_CSS_VARIABLE,);@@ -433,14 +440,71 @@ export const LogConsole = () => {setIsDetailPanelResizing(false);};+ const handleHeightPreview = (height: number) => {+ setLiveHeight(height);+ document.documentElement.style.setProperty(+ LOG_CONSOLE_HEIGHT_CSS_VARIABLE,+ `${height}px`,+ );+ };++ const handleDetailPanelWidthPreview = (width: number) => {+ setLiveDetailPanelWidth(width);+ document.documentElement.style.setProperty(+ LOG_CONSOLE_DETAIL_PANEL_CSS_VARIABLE,+ `${width}px`,+ );+ };++ const handleResizeEnd = ({+ cancelled,+ value,+ }: {+ cancelled: boolean;+ value: number;+ }) => {+ setLiveHeight(null);+ setIsResizing(false);+ document.documentElement.style.removeProperty(+ LOG_CONSOLE_HEIGHT_CSS_VARIABLE,+ );++ const isCancelledResizeFromCollapsed = cancelled && value === 0;+ const shouldRestoreCollapsedMode =+ isCancelledResizeFromCollapsed &&+ store.get(logConsoleDisplayModeState.atom) === 'open' &&+ !store.get(isLogConsoleFullScreenState.atom);++ if (shouldRestoreCollapsedMode) {+ setLogConsoleDisplayMode('collapsed');+ }+ };++ const handleDetailPanelResizeEnd = () => {+ setLiveDetailPanelWidth(null);+ setIsDetailPanelResizing(false);+ document.documentElement.style.removeProperty(+ LOG_CONSOLE_DETAIL_PANEL_CSS_VARIABLE,+ );+ };+const handleHeightChange = (height: number) => {+ setLiveHeight(null);setIsResizing(false);+ document.documentElement.style.removeProperty(+ LOG_CONSOLE_HEIGHT_CSS_VARIABLE,+ );if (height === 0) {setLogConsoleDisplayMode('collapsed');return;}+ if (!isOpen && height < LOG_CONSOLE_HEIGHT_CONSTRAINTS.min) {+ openLogConsole();+ return;+ }+setLogConsoleHeight(Math.max(height, LOG_CONSOLE_HEIGHT_CONSTRAINTS.min));openLogConsole();};@@ -602,13 +666,17 @@ export const LogConsole = () => {isResizing={isDetailPanelResizing}>{isDefined(logConsoleSelectedLog) && (- <ResizablePanelEdge- side="left"- constraints={LOG_CONSOLE_DETAIL_PANEL_WIDTH_CONSTRAINTS}- currentSize={detailPanelWidth}- onSizeChange={handleDetailPanelWidthChange}- cssVariableName={LOG_CONSOLE_DETAIL_PANEL_CSS_VARIABLE}- showHandle={false}+ <ResizeHandle+ edge="left"+ min={LOG_CONSOLE_DETAIL_PANEL_WIDTH_CONSTRAINTS.min}+ max={LOG_CONSOLE_DETAIL_PANEL_WIDTH_CONSTRAINTS.max}+ value={liveDetailPanelWidth ?? detailPanelWidth}+ onValueChange={handleDetailPanelWidthPreview}+ onValueCommitted={handleDetailPanelWidthChange}+ aria-label={t`Resize log details`}+ scale={getUiZoom}+ onResizeEnd={handleDetailPanelResizeEnd}+ children={null}onResizeStart={() => setIsDetailPanelResizing(true)}/>)}@@ -618,12 +686,16 @@ export const LogConsole = () => {)}</TabListRoot>{!displayedLayout.isFullScreen && (- <ResizablePanelEdge- side="top"- constraints={logConsoleResizeConstraints}- currentSize={isOpen ? logConsoleBodyHeight : 0}- onSizeChange={handleHeightChange}- cssVariableName={LOG_CONSOLE_HEIGHT_CSS_VARIABLE}+ <ResizeHandle+ edge="top"+ min={logConsoleResizeConstraints.min}+ max={logConsoleResizeConstraints.max}+ value={liveHeight ?? (isOpen ? logConsoleBodyHeight : 0)}+ onValueChange={handleHeightPreview}+ onValueCommitted={handleHeightChange}+ aria-label={t`Resize log console`}+ scale={getUiZoom}+ onResizeEnd={handleResizeEnd}onResizeStart={handleResizeStart}/>)}diff --git a/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsx b/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsxindex bd771cbe488..10f719b5e52 100644--- a/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsx+++ b/packages/twenty-front/src/modules/log-console/components/__tests__/LogConsole.test.tsx@@ -1,18 +1,22 @@import { i18n } from '@lingui/core';import { I18nProvider } from '@lingui/react';import { MockedProvider } from '@apollo/client/testing/react';-import { render, screen } from '@testing-library/react';+import { act, render, screen } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { Provider as JotaiProvider } from 'jotai';import { Suspense } from 'react';import { MemoryRouter } from 'react-router-dom';import { ToastProvider } from 'twenty-ui/components/feedback';+import { type ResizeHandleProps } from 'twenty-ui/primitives/layout';import { currentUserWorkspaceState } from '@/auth/states/currentUserWorkspaceState';import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';import { isClickHouseConfiguredState } from '@/client-config/states/isClickHouseConfiguredState';import { LogConsole } from '@/log-console/components/LogConsole';+import { LOG_CONSOLE_HEIGHT_CONSTRAINTS } from '@/log-console/constants/LogConsoleHeightConstraints';+import { isLogConsoleFullScreenState } from '@/log-console/states/isLogConsoleFullScreenState';import { logConsoleDisplayModeState } from '@/log-console/states/logConsoleDisplayModeState';+import { logConsoleHeightState } from '@/log-console/states/logConsoleHeightState';import { useSetAdvancedMode } from '@/navigation/hooks/useSetAdvancedMode';import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';@@ -29,6 +33,16 @@ import {mockedUserData,} from '~/testing/mock-data/users';+let capturedResizeHandleProps: ResizeHandleProps | undefined;++jest.mock('twenty-ui/primitives/layout', () => ({+ ...jest.requireActual('twenty-ui/primitives/layout'),+ ResizeHandle: (props: ResizeHandleProps) => {+ capturedResizeHandleProps = props;+ return null;+ },+}));+jest.mock('@/log-console/components/LogConsoleResults', () => ({LogConsoleResults: () => <div>Log results</div>,}));@@ -89,6 +103,131 @@ const renderWithLogsFeatureFlag = (isLogsFeatureFlagEnabled: boolean) => {};describe('LogConsole', () => {+ beforeEach(() => {+ capturedResizeHandleProps = undefined;+ });++ it('restores the collapsed console when its opening drag is cancelled', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');+ });+ act(() => capturedResizeHandleProps?.onResizeStart?.(100));++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('open');++ act(() =>+ capturedResizeHandleProps?.onResizeEnd?.({+ cancelled: true,+ value: 0,+ }),+ );++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('collapsed');+ });++ it('keeps an explicitly closed console closed when its drag is cancelled', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');+ });+ act(() => capturedResizeHandleProps?.onResizeStart?.(100));+ const onResizeEnd = capturedResizeHandleProps?.onResizeEnd;++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('open');++ act(() => jotaiStore.set(logConsoleDisplayModeState.atom, 'closed'));+ act(() => onResizeEnd?.({ cancelled: true, value: 0 }));++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('closed');+ });++ it('keeps the console open in full screen when its drag is cancelled', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');+ });+ act(() => capturedResizeHandleProps?.onResizeStart?.(100));+ const onResizeEnd = capturedResizeHandleProps?.onResizeEnd;++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('open');++ act(() => jotaiStore.set(isLogConsoleFullScreenState.atom, true));+ act(() => onResizeEnd?.({ cancelled: true, value: 0 }));++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('open');+ expect(jotaiStore.get(isLogConsoleFullScreenState.atom)).toBe(true);+ });++ it('restores the collapsed console when the cancel arrives before the drag start renders', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');+ });+ const onResizeStart = capturedResizeHandleProps?.onResizeStart;+ const onResizeEnd = capturedResizeHandleProps?.onResizeEnd;++ act(() => {+ onResizeStart?.(100);+ onResizeEnd?.({ cancelled: true, value: 0 });+ });++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('collapsed');+ });++ it('opens a collapsed console at its saved height on a small keyboard step', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleHeightState.atom, 450);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'collapsed');+ });++ act(() => capturedResizeHandleProps?.onValueCommitted?.(10));++ expect(jotaiStore.get(logConsoleDisplayModeState.atom)).toBe('open');+ expect(jotaiStore.get(logConsoleHeightState.atom)).toBe(450);+ });++ it('reflects live resizing without saving the console height until commit', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleHeightState.atom, 450);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'open');+ });++ act(() => capturedResizeHandleProps?.onValueChange?.(300));++ expect(capturedResizeHandleProps?.value).toBe(300);+ expect(jotaiStore.get(logConsoleHeightState.atom)).toBe(450);++ act(() => capturedResizeHandleProps?.onValueCommitted?.(300));++ expect(capturedResizeHandleProps?.value).toBe(300);+ expect(jotaiStore.get(logConsoleHeightState.atom)).toBe(300);+ });++ it('starts the resize range of an open console at its minimum height until a drag begins', () => {+ renderWithLogsFeatureFlag(true);+ act(() => {+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);+ jotaiStore.set(logConsoleDisplayModeState.atom, 'open');+ });++ expect(capturedResizeHandleProps?.min).toBe(+ LOG_CONSOLE_HEIGHT_CONSTRAINTS.min,+ );++ act(() => capturedResizeHandleProps?.onResizeStart?.(300));++ expect(capturedResizeHandleProps?.min).toBe(0);+ });+it('opens when developer mode is turned on', async () => {renderWithLogsFeatureFlag(true);diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelForDesktop.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelForDesktop.tsxindex 6d3a38d1b05..e26f82333dd 100644--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelForDesktop.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelForDesktop.tsx@@ -13,7 +13,9 @@ import {sidePanelWidthState,} from '@/side-panel/states/sidePanelWidthState';import { DialogContainerContext } from '@/ui/layout/dialog/contexts/DialogContainerContext';-import { ResizablePanelGap } from '@/ui/layout/resizable-panel/components/ResizablePanelGap';+import { ResizeHandle } from 'twenty-ui/primitives/layout';+import { useLingui } from '@lingui/react/macro';+import { getUiZoom } from '@/ui/theme/utils/getUiZoom';import { ParentClickOutsideIdContext } from '@/ui/utilities/pointer-event/contexts/ParentClickOutsideIdContext';import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';@@ -73,6 +75,7 @@ const StyledModalContainer = styled.div``;export const SidePanelForDesktop = () => {+ const { t } = useLingui();const store = useStore();const isSidePanelOpened = useAtomStateValue(isSidePanelOpenedState);const [sidePanelWidth, setSidePanelWidth] = useAtomState(sidePanelWidthState);@@ -85,6 +88,7 @@ export const SidePanelForDesktop = () => {null,);const [isResizing, setIsResizing] = useState(false);+ const [liveWidth, setLiveWidth] = useState<number | null>(null);const [shouldRenderContent, setShouldRenderContent] =useState(isSidePanelOpened);const [isShrinkingFromFullWidth, setIsShrinkingFromFullWidth] =@@ -139,12 +143,27 @@ export const SidePanelForDesktop = () => {const handleWidthChange = useCallback((width: number) => {setSidePanelWidth(width);+ setLiveWidth(null);setIsResizing(false);setTableWidthResizeIsActive(true);},[setSidePanelWidth, setTableWidthResizeIsActive],);+ const handleWidthPreview = (width: number) => {+ setLiveWidth(width);+ document.documentElement.style.setProperty(+ SIDE_PANEL_WIDTH_VAR,+ `${width}px`,+ );+ };++ const handleResizeEnd = () => {+ setLiveWidth(null);+ setIsResizing(false);+ setTableWidthResizeIsActive(true);+ };+const handleResizeStart = useCallback(() => {setIsResizing(true);setTableWidthResizeIsActive(false);@@ -152,6 +171,7 @@ export const SidePanelForDesktop = () => {const handleCollapse = useCallback(() => {closeSidePanelMenu();+ setLiveWidth(null);setIsResizing(false);setTableWidthResizeIsActive(true);}, [closeSidePanelMenu, setTableWidthResizeIsActive]);@@ -162,16 +182,22 @@ export const SidePanelForDesktop = () => {<SidePanelAskAiHandoffEffectonContinueChatFromFullWidth={handleContinueChatFromFullWidth}/>- <ResizablePanelGap- side="left"- constraints={SIDE_PANEL_CONSTRAINTS}- currentSize={sidePanelWidth}- onSizeChange={handleWidthChange}- onCollapse={handleCollapse}- gapWidth={0}- cssVariableName={SIDE_PANEL_WIDTH_VAR}- onResizeStart={handleResizeStart}- />+ {isSidePanelOpened && (+ <ResizeHandle+ edge="left"+ min={SIDE_PANEL_CONSTRAINTS.min}+ max={SIDE_PANEL_CONSTRAINTS.max}+ value={liveWidth ?? sidePanelWidth}+ onValueChange={handleWidthPreview}+ onValueCommitted={handleWidthChange}+ onActivate={handleCollapse}+ placement="gap"+ aria-label={t`Resize side panel`}+ scale={getUiZoom}+ onResizeEnd={handleResizeEnd}+ onResizeStart={handleResizeStart}+ />+ )}<StyledSidePanelWrapperisOpen={isSidePanelOpened}diff --git a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelForDesktop.test.tsx b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelForDesktop.test.tsxindex d86e6493c6a..7f43f0dc45e 100644--- a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelForDesktop.test.tsx+++ b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelForDesktop.test.tsx@@ -1,3 +1,5 @@+import { i18n } from '@lingui/core';+import { I18nProvider } from '@lingui/react';import { act, fireEvent, render } from '@testing-library/react';import { Provider as JotaiProvider } from 'jotai';import { type ReactNode } from 'react';@@ -37,8 +39,9 @@ jest.mock('@/side-panel/components/SidePanelWidthEffect', () => ({SidePanelWidthEffect: () => null,}));-jest.mock('@/ui/layout/resizable-panel/components/ResizablePanelGap', () => ({- ResizablePanelGap: () => null,+jest.mock('twenty-ui/primitives/layout', () => ({+ ...jest.requireActual('twenty-ui/primitives/layout'),+ ResizeHandle: () => null,}));jest.mock(@@ -56,7 +59,9 @@ jest.mock('@/side-panel/hooks/useSidePanelMenu', () => ({}));const Wrapper = ({ children }: { children: ReactNode }) => (- <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>+ <I18nProvider i18n={i18n}>+ <JotaiProvider store={jotaiStore}>{children}</JotaiProvider>+ </I18nProvider>);const startHandoffShrink = () => {diff --git a/packages/twenty-front/src/modules/side-panel/constants/SidePanelConstraints.ts b/packages/twenty-front/src/modules/side-panel/constants/SidePanelConstraints.tsindex 456654bb5d2..85694749210 100644--- a/packages/twenty-front/src/modules/side-panel/constants/SidePanelConstraints.ts+++ b/packages/twenty-front/src/modules/side-panel/constants/SidePanelConstraints.ts@@ -1,6 +1,4 @@-import { type ResizablePanelConstraints } from '@/ui/layout/resizable-panel/types/ResizablePanelConstraints';--export const SIDE_PANEL_CONSTRAINTS: ResizablePanelConstraints = {+export const SIDE_PANEL_CONSTRAINTS = {min: 320,max: 600,default: 400,diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/components/ResizablePanelEdge.tsx b/packages/twenty-front/src/modules/ui/layout/resizable-panel/components/ResizablePanelEdge.tsxdeleted file mode 100644index 9356d5d34bc..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/components/ResizablePanelEdge.tsx+++ /dev/null@@ -1,108 +0,0 @@-import { styled } from '@linaria/react';--import { RESIZE_EDGE_WIDTH_PX } from '@/ui/layout/resizable-panel/constants/ResizeEdgeWidthPx';-import { useResizablePanel } from '@/ui/layout/resizable-panel/hooks/useResizablePanel';-import { type ResizablePanelConstraints } from '@/ui/layout/resizable-panel/types/ResizablePanelConstraints';-import { type ResizablePanelSide } from '@/ui/layout/resizable-panel/types/ResizablePanelSide';-import { themeCssVariables } from 'twenty-ui/theme';--type StyledEdgeProps = {- isActive: boolean;- isHovered: boolean;- side: ResizablePanelSide;-};--const StyledEdge = styled.div<StyledEdgeProps>`- align-items: center;- bottom: ${({ side }) => (side === 'top' ? 'auto' : '0')};- cursor: ${({ side }) => (side === 'top' ? 'row-resize' : 'col-resize')};- display: flex;- height: ${({ side }) =>- side === 'top' ? `${RESIZE_EDGE_WIDTH_PX}px` : 'auto'};- justify-content: center;- left: ${({ side }) =>- side === 'left' ? `-${RESIZE_EDGE_WIDTH_PX / 2}px` : 'auto'};- position: absolute;-- right: ${({ side }) =>- side === 'right' ? `-${RESIZE_EDGE_WIDTH_PX / 2}px` : 'auto'};- top: 0;- width: ${({ side }) =>- side === 'top' ? '100%' : `${RESIZE_EDGE_WIDTH_PX}px`};-`;--const StyledHandle = styled.div<{- isActive: boolean;- isHovered: boolean;- side: ResizablePanelSide;-}>`- background-color: ${({ isActive, isHovered }) =>- isActive || isHovered- ? themeCssVariables.border.color.strong- : themeCssVariables.background.quaternary};- border-radius: ${themeCssVariables.border.radius.pill};- corner-shape: round;- height: ${({ side }) => (side === 'top' ? '3px' : '48px')};- transform: ${({ isHovered, isActive, side }) => {- const scale = isHovered || isActive ? 1.2 : 1;-- return side === 'top' ? `scaleX(${scale})` : `scaleY(${scale})`;- }};- transition:- background-color ${themeCssVariables.animation.duration.fast}s,- transform ${themeCssVariables.animation.duration.fast}s;- width: ${({ side }) => (side === 'top' ? '48px' : '4px')};-`;--type ResizablePanelEdgeProps = {- side: ResizablePanelSide;- constraints: ResizablePanelConstraints;- currentSize: number;- onSizeChange: (size: number) => void;- onCollapse?: () => void;- showHandle?: boolean;- cssVariableName?: string;- onResizeStart?: (size: number) => void;-};--export const ResizablePanelEdge = ({- side,- constraints,- currentSize,- onSizeChange,- onCollapse,- showHandle = true,- cssVariableName,- onResizeStart,-}: ResizablePanelEdgeProps) => {- const {- isHovered,- isResizing,- handleMouseDown,- handleMouseEnter,- handleMouseLeave,- } = useResizablePanel({- side,- constraints,- currentSize,- onSizeChange,- onCollapse,- cssVariableName,- onResizeStart,- });-- return (- <StyledEdge- side={side}- isActive={isResizing}- isHovered={isHovered}- onMouseDown={handleMouseDown}- onMouseEnter={handleMouseEnter}- onMouseLeave={handleMouseLeave}- >- {showHandle && (- <StyledHandle side={side} isActive={isResizing} isHovered={isHovered} />- )}- </StyledEdge>- );-};diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/components/ResizablePanelGap.tsx b/packages/twenty-front/src/modules/ui/layout/resizable-panel/components/ResizablePanelGap.tsxdeleted file mode 100644index 87cbac895d6..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/components/ResizablePanelGap.tsx+++ /dev/null@@ -1,62 +0,0 @@-import { styled } from '@linaria/react';--import { useResizablePanel } from '@/ui/layout/resizable-panel/hooks/useResizablePanel';-import { type ResizablePanelConstraints } from '@/ui/layout/resizable-panel/types/ResizablePanelConstraints';-import { type ResizablePanelSide } from '@/ui/layout/resizable-panel/types/ResizablePanelSide';--// Horizontal padding offset by an equal negative margin keeps the resize-// handle grabbable even when the visual gap is 0, without shifting neighbors.-const StyledGap = styled.div<{ gapWidth: number }>`- box-sizing: content-box;- cursor: col-resize;- flex-shrink: 0;- height: 100%;- margin: 0 -4px;- padding: 0 4px;- position: relative;- transition: width 0.15s ease;- width: ${({ gapWidth }) => gapWidth}px;- z-index: 1;-`;--type ResizablePanelGapProps = {- side: ResizablePanelSide;- constraints: ResizablePanelConstraints;- currentSize: number;- onSizeChange: (size: number) => void;- onCollapse?: () => void;- gapWidth: number;- cssVariableName?: string;- onResizeStart?: () => void;-};--export const ResizablePanelGap = ({- side,- constraints,- currentSize,- onSizeChange,- onCollapse,- gapWidth,- cssVariableName,- onResizeStart,-}: ResizablePanelGapProps) => {- const { handleMouseDown, handleMouseEnter, handleMouseLeave } =- useResizablePanel({- side,- constraints,- currentSize,- onSizeChange,- onCollapse,- cssVariableName,- onResizeStart,- });-- return (- <StyledGap- gapWidth={gapWidth}- onMouseDown={handleMouseDown}- onMouseEnter={handleMouseEnter}- onMouseLeave={handleMouseLeave}- />- );-};diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/NavigationDrawerConstraints.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/NavigationDrawerConstraints.tsdeleted file mode 100644index 99373a445d4..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/NavigationDrawerConstraints.ts+++ /dev/null@@ -1,7 +0,0 @@-import { type ResizablePanelConstraints } from '@/ui/layout/resizable-panel/types/ResizablePanelConstraints';--export const NAVIGATION_DRAWER_CONSTRAINTS: ResizablePanelConstraints = {- min: 180,- max: 350,- default: 220,-};diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/ResizeDragThresholdPx.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/ResizeDragThresholdPx.tsdeleted file mode 100644index 7db7dfbf921..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/ResizeDragThresholdPx.ts+++ /dev/null@@ -1 +0,0 @@-export const RESIZE_DRAG_THRESHOLD_PX = 5;diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/ResizeEdgeWidthPx.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/ResizeEdgeWidthPx.tsdeleted file mode 100644index acd763050a9..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/ResizeEdgeWidthPx.ts+++ /dev/null@@ -1 +0,0 @@-export const RESIZE_EDGE_WIDTH_PX = 8;diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/hooks/__tests__/useResizablePanel.test.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/hooks/__tests__/useResizablePanel.test.tsdeleted file mode 100644index 87b2ee40fa3..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/hooks/__tests__/useResizablePanel.test.ts+++ /dev/null@@ -1,31 +0,0 @@-import { renderHook } from '@testing-library/react';--import { useResizablePanel } from '@/ui/layout/resizable-panel/hooks/useResizablePanel';--const CSS_VARIABLE_NAME = '--test-panel-width';--describe('useResizablePanel', () => {- afterEach(() => {- document.documentElement.style.removeProperty(CSS_VARIABLE_NAME);- });-- it('keeps the CSS variable set by its owner when the panel unmounts', () => {- document.documentElement.style.setProperty(CSS_VARIABLE_NAME, '240px');-- const { unmount } = renderHook(() =>- useResizablePanel({- side: 'right',- constraints: { min: 200, max: 400, default: 240 },- currentSize: 240,- onSizeChange: jest.fn(),- cssVariableName: CSS_VARIABLE_NAME,- }),- );-- unmount();-- expect(- document.documentElement.style.getPropertyValue(CSS_VARIABLE_NAME),- ).toBe('240px');- });-});diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/hooks/useResizablePanel.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/hooks/useResizablePanel.tsdeleted file mode 100644index 0b6e5f5506b..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/hooks/useResizablePanel.ts+++ /dev/null@@ -1,158 +0,0 @@-import { useCallback, useRef, useState } from 'react';-import { isDefined } from 'twenty-shared/utils';--import { getUiZoom } from '@/ui/theme/utils/getUiZoom';-import { useTrackPointer } from '@/ui/utilities/pointer-event/hooks/useTrackPointer';-import { type PointerEventListener } from '@/ui/utilities/pointer-event/types/PointerEventListener';--import { RESIZE_DRAG_THRESHOLD_PX } from '@/ui/layout/resizable-panel/constants/ResizeDragThresholdPx';-import { type ResizablePanelConstraints } from '@/ui/layout/resizable-panel/types/ResizablePanelConstraints';-import { type ResizablePanelSide } from '@/ui/layout/resizable-panel/types/ResizablePanelSide';--type UseResizablePanelProps = {- side: ResizablePanelSide;- constraints: ResizablePanelConstraints;- currentSize: number;- onSizeChange: (size: number) => void;- onCollapse?: () => void;- cssVariableName?: string;- onResizeStart?: (size: number) => void;-};--const clampSize = (size: number, min: number, max: number): number =>- Math.min(max, Math.max(min, size));--export const useResizablePanel = ({- side,- constraints,- currentSize,- onSizeChange,- onCollapse,- cssVariableName,- onResizeStart,-}: UseResizablePanelProps) => {- const [isHovered, setIsHovered] = useState(false);- const [isResizing, setIsResizing] = useState(false);- const [startPointerPosition, setStartPointerPosition] = useState<- number | null- >(null);- const [startSize, setStartSize] = useState<number>(0);- // eslint-disable-next-line twenty/no-state-useref -- pointer callbacks read this synchronously; useState causes stale closures- const hasDraggedRef = useRef(false);-- // reading computed style on every pointer move forces a synchronous style recalc; zoom cannot change mid-drag- const [dragUiZoom, setDragUiZoom] = useState(1);-- const handleResizeMove = useCallback<PointerEventListener>(- ({ x, y }) => {- if (startPointerPosition === null) return;-- const pointerDelta =- ((side === 'top' ? y : x) - startPointerPosition) / dragUiZoom;-- if (Math.abs(pointerDelta) <= RESIZE_DRAG_THRESHOLD_PX) {- return;- }-- const sizeDelta = side === 'right' ? pointerDelta : -pointerDelta;- const clampedSize = clampSize(- startSize + sizeDelta,- constraints.min,- constraints.max,- );-- if (!hasDraggedRef.current) {- hasDraggedRef.current = true;- onResizeStart?.(clampedSize);- }-- if (isDefined(cssVariableName)) {- document.documentElement.style.setProperty(- cssVariableName,- `${clampedSize}px`,- );- }- },- [- dragUiZoom,- startPointerPosition,- startSize,- side,- constraints.min,- constraints.max,- cssVariableName,- onResizeStart,- ],- );-- const handleResizeEnd = useCallback<PointerEventListener>(- ({ x, y }) => {- if (startPointerPosition === null) {- setIsResizing(false);- return;- }-- const pointerDelta =- ((side === 'top' ? y : x) - startPointerPosition) / dragUiZoom;-- if (hasDraggedRef.current) {- const sizeDelta = side === 'right' ? pointerDelta : -pointerDelta;- const finalSize = clampSize(- startSize + sizeDelta,- constraints.min,- constraints.max,- );- onSizeChange(finalSize);- } else {- onCollapse?.();- }-- setStartPointerPosition(null);- setIsResizing(false);- },- [- dragUiZoom,- startPointerPosition,- startSize,- side,- constraints.min,- constraints.max,- onSizeChange,- onCollapse,- ],- );-- useTrackPointer({- shouldTrackPointer: isResizing,- onMouseMove: handleResizeMove,- onMouseUp: handleResizeEnd,- });-- const handleMouseDown = useCallback(- (event: React.MouseEvent) => {- event.preventDefault();- setDragUiZoom(getUiZoom());- setStartPointerPosition(side === 'top' ? event.clientY : event.clientX);- setStartSize(currentSize);- hasDraggedRef.current = false;- setIsResizing(true);- },- [side, currentSize],- );-- const handleMouseEnter = useCallback(() => {- setIsHovered(true);- }, []);-- const handleMouseLeave = useCallback(() => {- setIsHovered(false);- }, []);-- return {- isHovered,- isResizing,- handleMouseDown,- handleMouseEnter,- handleMouseLeave,- };-};diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/types/ResizablePanelConstraints.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/types/ResizablePanelConstraints.tsdeleted file mode 100644index 0ef13e834ec..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/types/ResizablePanelConstraints.ts+++ /dev/null@@ -1,5 +0,0 @@-export type ResizablePanelConstraints = {- min: number;- max: number;- default: number;-};diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/types/ResizablePanelSide.ts b/packages/twenty-front/src/modules/ui/layout/resizable-panel/types/ResizablePanelSide.tsdeleted file mode 100644index c8dd26c849f..00000000000--- a/packages/twenty-front/src/modules/ui/layout/resizable-panel/types/ResizablePanelSide.ts+++ /dev/null@@ -1 +0,0 @@-export type ResizablePanelSide = 'left' | 'right' | 'top';diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsxindex 22fbb0ef4a6..3a84cc565e2 100644--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawer.tsx@@ -1,11 +1,13 @@import { styled } from '@linaria/react';-import { type ReactNode, useState } from 'react';+import { type ReactNode, useRef, useState } from 'react';import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';import { tableWidthResizeIsActiveState } from '@/object-record/record-table/states/tableWidthResizeIsActivedState';-import { ResizablePanelEdge } from '@/ui/layout/resizable-panel/components/ResizablePanelEdge';-import { NAVIGATION_DRAWER_COLLAPSED_WIDTH } from '@/ui/layout/resizable-panel/constants/NavigationDrawerCollapsedWidth';-import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/layout/resizable-panel/constants/NavigationDrawerConstraints';+import { ResizeHandle } from 'twenty-ui/primitives/layout';+import { useLingui } from '@lingui/react/macro';+import { getUiZoom } from '@/ui/theme/utils/getUiZoom';+import { NAVIGATION_DRAWER_COLLAPSED_WIDTH } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerCollapsedWidth';+import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints';import { NavigationDrawerWidthEffect } from '@/ui/navigation/components/NavigationDrawerWidthEffect';import { NAVIGATION_DRAWER_CLICK_OUTSIDE_ID } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerClickOutsideId';import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';@@ -15,6 +17,7 @@ import {NAVIGATION_DRAWER_WIDTH_VAR,navigationDrawerWidthState,} from '@/ui/navigation/states/navigationDrawerWidthState';+import { shouldFocusNavigationDrawerExpandButtonState } from '@/ui/navigation/navigation-drawer/states/shouldFocusNavigationDrawerExpandButtonState';import { useIsMobile } from 'twenty-ui/utilities';import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';@@ -32,7 +35,7 @@ const StyledAnimatedContainer = styled.div<{}>`height: 100%;max-height: 100%;- overflow: hidden;+ overflow: clip;position: relative;transition: ${({ isResizing }) =>isResizing@@ -82,7 +85,10 @@ export const NavigationDrawer = ({children,className,}: NavigationDrawerProps) => {+ const { t } = useLingui();+ const resizeHandleRef = useRef<HTMLDivElement>(null);const [isResizing, setIsResizing] = useState(false);+ const [liveWidth, setLiveWidth] = useState<number | null>(null);const isMobile = useIsMobile();const isExpanded = useNavigationDrawerExpanded();@@ -97,9 +103,16 @@ export const NavigationDrawer = ({const setTableWidthResizeIsActive = useSetAtomState(tableWidthResizeIsActiveState,);+ const setShouldFocusNavigationDrawerExpandButton = useSetAtomState(+ shouldFocusNavigationDrawerExpandButtonState,+ );const handleCollapse = () => {+ setShouldFocusNavigationDrawerExpandButton(+ resizeHandleRef.current === document.activeElement,+ );setIsNavigationDrawerExpanded(false);+ setLiveWidth(null);setNavigationDrawerActiveTab(NAVIGATION_DRAWER_TABS.NAVIGATION_MENU);setIsResizing(false);setTableWidthResizeIsActive(true);@@ -107,11 +120,26 @@ export const NavigationDrawer = ({const handleWidthChange = (width: number) => {setNavigationDrawerWidth(width);+ setLiveWidth(null);+ setIsResizing(false);+ setTableWidthResizeIsActive(true);+ };++ const handleWidthPreview = (width: number) => {+ setLiveWidth(width);+ document.documentElement.style.setProperty(+ NAVIGATION_DRAWER_WIDTH_VAR,+ `${width}px`,+ );+ };++ const handleResizeEnd = () => {+ setLiveWidth(null);setIsResizing(false);setTableWidthResizeIsActive(true);};- const handleResizeStart = (_size: number) => {+ const handleResizeStart = () => {setIsResizing(true);setTableWidthResizeIsActive(false);};@@ -131,14 +159,19 @@ export const NavigationDrawer = ({</StyledContainer>{isNavigationDrawerExpanded && !isMobile && (- <ResizablePanelEdge- side="right"- constraints={NAVIGATION_DRAWER_CONSTRAINTS}- currentSize={navigationDrawerWidth}- onSizeChange={handleWidthChange}- onCollapse={handleCollapse}- showHandle={false}- cssVariableName={NAVIGATION_DRAWER_WIDTH_VAR}+ <ResizeHandle+ ref={resizeHandleRef}+ edge="right"+ min={NAVIGATION_DRAWER_CONSTRAINTS.min}+ max={NAVIGATION_DRAWER_CONSTRAINTS.max}+ value={liveWidth ?? navigationDrawerWidth}+ onValueChange={handleWidthPreview}+ onValueCommitted={handleWidthChange}+ onActivate={handleCollapse}+ children={null}+ aria-label={t`Resize navigation drawer`}+ scale={getUiZoom}+ onResizeEnd={handleResizeEnd}onResizeStart={handleResizeStart}/>)}diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsxindex 7d60686a139..90185490dc7 100644--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx@@ -2,6 +2,7 @@ import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';import { useNavigationDrawerTogglePresentation } from '@/navigation/hooks/useNavigationDrawerTogglePresentation';import { useToggleNavigationDrawer } from '@/navigation/hooks/useToggleNavigationDrawer';import { TooltipDelay } from '@/ui/layout/tooltip/constants/TooltipDelay';+import { useNavigationDrawerExpandButtonFocusHandOff } from '@/ui/navigation/navigation-drawer/hooks/useNavigationDrawerExpandButtonFocusHandOff';import { useIsMobile } from 'twenty-ui/utilities';import { styled } from '@linaria/react';import { LightIconButton } from 'twenty-ui/components/input';@@ -33,6 +34,8 @@ export const NavigationDrawerCollapseButton = ({const { label, Icon } = useNavigationDrawerTogglePresentation(direction === 'left',);+ const expandButtonFocusHandOffRef =+ useNavigationDrawerExpandButtonFocusHandOff();// The main navigation is a page on mobile, so there is no drawer to toggle.if (isMobile && !isSettingsDrawer) {@@ -48,6 +51,7 @@ export const NavigationDrawerCollapseButton = ({><StyledCollapseButton className={className}><LightIconButton+ ref={direction === 'right' ? expandButtonFocusHandOffRef : undefined}emphasis="standard"size="sm"onClick={toggleNavigationDrawer}diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__tests__/NavigationDrawer.test.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__tests__/NavigationDrawer.test.tsxnew file mode 100644index 00000000000..f175184664f--- /dev/null+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__tests__/NavigationDrawer.test.tsx@@ -0,0 +1,121 @@+import { i18n } from '@lingui/core';+import { I18nProvider } from '@lingui/react';+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { Provider as JotaiProvider } from 'jotai';+import { type ReactNode } from 'react';+import { MemoryRouter } from 'react-router-dom';++import { NavigationDrawer } from '@/ui/navigation/navigation-drawer/components/NavigationDrawer';+import { NavigationDrawerCollapseButton } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton';+import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import {+ jotaiStore,+ resetJotaiStore,+} from '@/ui/utilities/state/jotai/jotaiStore';++jest.mock(+ '@/ui/navigation/navigation-drawer/components/NavigationDrawerHeader',+ () => ({+ NavigationDrawerHeader: () => null,+ }),+);++const PageHeaderExpandButton = () => {+ const isNavigationDrawerExpanded = useAtomStateValue(+ isNavigationDrawerExpandedState,+ );++ return isNavigationDrawerExpanded ? null : (+ <NavigationDrawerCollapseButton direction="right" />+ );+};++const NavigationDrawerTestProviders = ({+ children,+}: {+ children: ReactNode;+}) => (+ <I18nProvider i18n={i18n}>+ <JotaiProvider store={jotaiStore}>+ <MemoryRouter>{children}</MemoryRouter>+ </JotaiProvider>+ </I18nProvider>+);++const NavigationDrawerPage = ({+ hasPageHeader,+}: {+ hasPageHeader: boolean;+}) => (+ <>+ <NavigationDrawer />+ {hasPageHeader && <PageHeaderExpandButton />}+ <button type="button">Page action</button>+ </>+);++const renderNavigationDrawerPage = ({+ hasPageHeader,+}: {+ hasPageHeader: boolean;+}) => {+ resetJotaiStore();+ jotaiStore.set(isNavigationDrawerExpandedState.atom, true);++ return render(<NavigationDrawerPage hasPageHeader={hasPageHeader} />, {+ wrapper: NavigationDrawerTestProviders,+ });+};++describe('NavigationDrawer', () => {+ it('moves focus to the expand button when the keyboard collapses the drawer from its resize separator', async () => {+ renderNavigationDrawerPage({ hasPageHeader: true });++ await userEvent.tab();++ expect(+ screen.getByRole('separator', { name: 'Resize navigation drawer' }),+ ).toHaveFocus();++ await userEvent.keyboard('{Enter}');++ expect(jotaiStore.get(isNavigationDrawerExpandedState.atom)).toBe(false);+ expect(+ screen.getByRole('button', { name: 'Expand sidebar' }),+ ).toHaveFocus();+ });++ it('keeps focus where it was when the resize separator is clicked', async () => {+ renderNavigationDrawerPage({ hasPageHeader: true });+ const pageActionButton = screen.getByRole('button', {+ name: 'Page action',+ });++ pageActionButton.focus();+ await userEvent.click(+ screen.getByRole('separator', { name: 'Resize navigation drawer' }),+ );++ expect(jotaiStore.get(isNavigationDrawerExpandedState.atom)).toBe(false);+ expect(pageActionButton).toHaveFocus();+ });++ it('does not steal focus when the expand button mounts after the keyboard collapse', async () => {+ const { rerender } = renderNavigationDrawerPage({ hasPageHeader: false });+ const pageActionButton = screen.getByRole('button', {+ name: 'Page action',+ });++ await userEvent.tab();+ await userEvent.keyboard('{Enter}');+ pageActionButton.focus();+ rerender(<NavigationDrawerPage hasPageHeader />);++ expect(+ screen.getByRole('button', { name: 'Expand sidebar' }),+ ).not.toHaveFocus();+ expect(pageActionButton).toHaveFocus();+ });+});diff --git a/packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/NavigationDrawerCollapsedWidth.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/NavigationDrawerCollapsedWidth.tssimilarity index 100%rename from packages/twenty-front/src/modules/ui/layout/resizable-panel/constants/NavigationDrawerCollapsedWidth.tsrename to packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/NavigationDrawerCollapsedWidth.tsdiff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints.tsnew file mode 100644index 00000000000..abd89048f10--- /dev/null+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints.ts@@ -0,0 +1,5 @@+export const NAVIGATION_DRAWER_CONSTRAINTS = {+ min: 180,+ max: 350,+ default: 220,+};diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationDrawerExpandButtonFocusHandOff.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationDrawerExpandButtonFocusHandOff.tsnew file mode 100644index 00000000000..61dd2d5dee7--- /dev/null+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/hooks/useNavigationDrawerExpandButtonFocusHandOff.ts@@ -0,0 +1,29 @@+import { useStore } from 'jotai';+import { useCallback } from 'react';+import { isDefined } from 'twenty-shared/utils';++import { shouldFocusNavigationDrawerExpandButtonState } from '@/ui/navigation/navigation-drawer/states/shouldFocusNavigationDrawerExpandButtonState';++export const useNavigationDrawerExpandButtonFocusHandOff = () => {+ const store = useStore();++ return useCallback(+ (expandButton: HTMLButtonElement | null) => {+ if (+ !isDefined(expandButton) ||+ !store.get(shouldFocusNavigationDrawerExpandButtonState.atom)+ ) {+ return;+ }++ store.set(shouldFocusNavigationDrawerExpandButtonState.atom, false);++ const isFocusLost = document.activeElement === document.body;++ if (isFocusLost) {+ expandButton.focus();+ }+ },+ [store],+ );+};diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/states/shouldFocusNavigationDrawerExpandButtonState.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/states/shouldFocusNavigationDrawerExpandButtonState.tsnew file mode 100644index 00000000000..ce8940aae99--- /dev/null+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/states/shouldFocusNavigationDrawerExpandButtonState.ts@@ -0,0 +1,7 @@+import { createAtomState } from '@/ui/utilities/state/jotai/utils/createAtomState';++export const shouldFocusNavigationDrawerExpandButtonState =+ createAtomState<boolean>({+ key: 'shouldFocusNavigationDrawerExpandButtonState',+ defaultValue: false,+ });diff --git a/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerWidthState.ts b/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerWidthState.tsindex 52a0b0adf40..f36573005bb 100644--- a/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerWidthState.ts+++ b/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerWidthState.ts@@ -1,4 +1,4 @@-import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/layout/resizable-panel/constants/NavigationDrawerConstraints';+import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerConstraints';import { createAtomState } from '@/ui/utilities/state/jotai/utils/createAtomState';export const NAVIGATION_DRAWER_WIDTH_VAR = '--navigation-drawer-width';diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 440b69fe3f0..d1faa1cf7d2 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -184,7 +184,15 @@ export const DOCUMENTED_COMPONENTS = [entryPoint: 'twenty-ui/primitives/layout',slug: 'layout/resize-handle',propDescriptions: RESIZE_HANDLE_PROP_DESCRIPTIONS,- propDefaults: { defaultValue: '150', min: '50', max: '500', step: '10' },+ propDefaults: {+ axis: 'y without edge',+ defaultValue: '150',+ dragThreshold: '5 with edge; 0 otherwise',+ min: '50',+ max: '500',+ placement: 'edge with edge; inline otherwise',+ step: '10',+ },},{name: 'DirectionProvider',diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.mdindex 738fb50cc19..ead60c958b0 100644--- a/packages/twenty-ui/docs/label-ownership.md+++ b/packages/twenty-ui/docs/label-ownership.md@@ -18,10 +18,10 @@ This covers production exports under components, primitives, and icons, includin| Toast and Toaster | Children, description and action slots, `iconLabel`, `cancelLabel` (default `Cancel`), and `closeLabel` (default `Close`). Toaster accepts native accessible attributes over its `Notifications` region default. || Chip and Avatar | Chip `emptyLabel` defaults to `Untitled`. Avatar accepts native accessible names over its interactive fallback of the supplied name or `Avatar`. The visual initial or dash is hidden from assistive technology; the image has empty alternative text. || JsonTree | Callers supply empty string, array, and object labels and expanded/collapsed arrow names. JSON booleans, null, property names, and values are data. |-| ResizeHandle and CodeEditor | ResizeHandle accepts native labels over `Resize`. CodeEditor exposes `resizeLabel` (default `Resize editor`) and Monaco `options`, including its editor accessible label. The loading indicator adds no text. Monaco owns its internal editor messages. |+| ResizeHandle and CodeEditor | ResizeHandle accepts native labels over `Resize`. Hosts supply a contextual label, `aria-controls`, and the focus destination when collapsing a panel removes its handle. CodeEditor exposes `resizeLabel` (default `Resize editor`) and Monaco `options`, including its editor accessible label. The loading indicator adds no text. Monaco owns its internal editor messages. || Input, Textarea, Select, Field, Slider, Radio, RadioGroup, Checkbox, Switch, SegmentedControl | Native attributes, compound label/description/error parts, options, and children belong to the caller. Browser validation messages remain browser-owned; Field.Error children or render content can replace them. || Dialog, AlertDialog, Popover, Tooltip, Tabs | Text belongs to title, description, close, trigger, tab, and popup parts. No built-in English action or status strings. |-| Banner, InlineBanner, SettingsRow, Section, CommandBlock | Content and labels belong to supplied props or children. |+| Banner, InlineBanner, SettingsRow, Section, CommandBlock | Content and labels belong to supplied props or children. || Tag, Status, Pill, AvatarGroup, NotificationCounter, ColorSample, TintedIconTile, typography, layout and icon exports | Caller content, data values, native accessible attributes where supported, or decorative output. Loader and progress graphics add no built-in English loading message. |Shortcut owns symbol and separator formatting for visual hints and strings. Flat key arrays represent simultaneous combinations; nested key arrays represent ordered sequences of combinations. Hosts supply `sequenceJoinLabel` (default `then`), optional `combinationSeparator`, and native accessible labels. The `shortcutJoinLabel` props on host controls forward the sequence label.diff --git a/packages/twenty-ui/docs/resizeHandlePropDescriptions.ts b/packages/twenty-ui/docs/resizeHandlePropDescriptions.tsindex 2cf8aab48e6..d41d3d05b6c 100644--- a/packages/twenty-ui/docs/resizeHandlePropDescriptions.ts+++ b/packages/twenty-ui/docs/resizeHandlePropDescriptions.ts@@ -3,11 +3,28 @@ import { type ComponentProps } from 'react';import { type ResizeHandle } from '../src/primitives/layout/ResizeHandle/ResizeHandle';export const RESIZE_HANDLE_PROP_DESCRIPTIONS = {- axis: 'Pointer movement axis: `y` for height or `x` for width.',- value: 'Controlled size. Apply the value to the element being resized.',+ axis: 'Pointer movement axis without `edge`: `y` for height or `x` for width.',+ direction:+ 'Physical increasing direction. Omit to follow the horizontal text direction; use `normal` or `reverse` for a fixed physical edge.',+ edge: 'Physical panel edge. Determines the movement axis and increasing direction, independently of text direction.',+ placement:+ 'Layout mode: `inline` stays in normal flow, `edge` positions the handle on the panel edge, and `gap` sits between panels. Defaults to `edge` when `edge` is set and `inline` otherwise.',+ scale:+ 'Pointer scale or resolver sampled at pointer down. Movement is divided by this positive scale; keyboard steps are unchanged.',+ dragThreshold:+ 'Physical pointer distance required before resizing starts. Movement below the threshold remains a click. Defaults to 5 with `edge` and 0 otherwise.',+ value:+ 'Current controlled size. Update it in `onValueChange` and apply it to the element being resized.',defaultValue: 'Initial size when the handle owns its state.',onValueChange:- 'Called with the bounded size after pointer or keyboard interaction.',+ 'Called with the bounded size during pointer or keyboard interaction and with the restored value on cancellation.',+ onValueCommitted:+ 'Called with the final size after a successful drag or an effective keyboard size change. Cancellation does not commit.',+ onResizeStart:+ 'Called once with the first bounded drag value after the threshold is crossed.',+ onResizeEnd:+ 'Called after a started drag ends, with its final value and whether it was cancelled. Cancellation restores the starting value within the current bounds.',+ onActivate: 'Called for a click without dragging, Enter, or Space.',min: 'Minimum allowed size.',max: 'Maximum allowed size.',step: 'Keyboard arrow increment. Pointer movement uses the pixel delta.',diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 0d24ef18d51..cebc80e3590 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -978,8 +978,8 @@"name": "axis","type": "\"x\" | \"y\"","required": false,- "defaultValue": "y",- "description": "Pointer movement axis: `y` for height or `x` for width."+ "defaultValue": "y without edge",+ "description": "Pointer movement axis without `edge`: `y` for height or `x` for width."},{"name": "defaultValue",@@ -988,6 +988,13 @@"defaultValue": "150","description": "Initial size when the handle owns its state."},+ {+ "name": "direction",+ "type": "\"normal\" | \"reverse\"",+ "required": false,+ "defaultValue": null,+ "description": "Physical increasing direction. Omit to follow the horizontal text direction; use `normal` or `reverse` for a fixed physical edge."+ },{"name": "disabled","type": "boolean",@@ -995,6 +1002,20 @@"defaultValue": "false","description": "Disables resizing and removes the handle from the tab order."},+ {+ "name": "dragThreshold",+ "type": "number",+ "required": false,+ "defaultValue": "5 with edge; 0 otherwise",+ "description": "Physical pointer distance required before resizing starts. Movement below the threshold remains a click. Defaults to 5 with `edge` and 0 otherwise."+ },+ {+ "name": "edge",+ "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",+ "required": false,+ "defaultValue": null,+ "description": "Physical panel edge. Determines the movement axis and increasing direction, independently of text direction."+ },{"name": "max","type": "number",@@ -1009,12 +1030,47 @@"defaultValue": "50","description": "Minimum allowed size."},+ {+ "name": "onActivate",+ "type": "(() => void)",+ "required": false,+ "defaultValue": null,+ "description": "Called for a click without dragging, Enter, or Space."+ },+ {+ "name": "onResizeEnd",+ "type": "((details: { cancelled: boolean; value: number; }) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Called after a started drag ends, with its final value and whether it was cancelled. Cancellation restores the starting value within the current bounds."+ },+ {+ "name": "onResizeStart",+ "type": "((value: number) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Called once with the first bounded drag value after the threshold is crossed."+ },{"name": "onValueChange","type": "((value: number) => void)","required": false,"defaultValue": null,- "description": "Called with the bounded size after pointer or keyboard interaction."+ "description": "Called with the bounded size during pointer or keyboard interaction and with the restored value on cancellation."+ },+ {+ "name": "onValueCommitted",+ "type": "((value: number) => void)",+ "required": false,+ "defaultValue": null,+ "description": "Called with the final size after a successful drag or an effective keyboard size change. Cancellation does not commit."+ },+ {+ "name": "placement",+ "type": "\"edge\" | \"gap\" | \"inline\"",+ "required": false,+ "defaultValue": "edge with edge; inline otherwise",+ "description": "Layout mode: `inline` stays in normal flow, `edge` positions the handle on the panel edge, and `gap` sits between panels. Defaults to `edge` when `edge` is set and `inline` otherwise."},{"name": "render",@@ -1023,6 +1079,13 @@"defaultValue": null,"description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."},+ {+ "name": "scale",+ "type": "number | (() => number)",+ "required": false,+ "defaultValue": "1",+ "description": "Pointer scale or resolver sampled at pointer down. Movement is divided by this positive scale; keyboard steps are unchanged."+ },{"name": "step","type": "number",@@ -1035,7 +1098,7 @@"type": "number","required": false,"defaultValue": null,- "description": "Controlled size. Apply the value to the element being resized."+ "description": "Current controlled size. Update it in `onValueChange` and apply it to the element being resized."}]},diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.module.scss b/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.module.scssindex f191a281142..ba408d0e352 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.module.scss+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.module.scss@@ -21,6 +21,65 @@cursor: default;opacity: 0.5;}++ &[data-edge]:not([data-disabled])[data-axis='x'] {+ cursor: col-resize;+ }++ &[data-edge]:not([data-disabled])[data-axis='y'] {+ cursor: row-resize;+ }++ &[data-placement='edge'] {+ position: absolute;+ inset-block: auto;+ inset-inline: auto;+ top: 0;+ }++ &[data-placement='edge'][data-axis='x'] {+ bottom: 0;+ width: 8px;+ }++ &[data-placement='edge'][data-edge='left'] {+ left: -4px;+ }++ &[data-placement='edge'][data-edge='right'] {+ right: -4px;+ }++ &[data-placement='edge'][data-axis='y'] {+ left: 0;+ right: 0;+ height: 8px;+ }++ &[data-placement='edge'][data-edge='bottom'] {+ top: auto;+ bottom: 0;+ }++ &[data-placement='gap'] {+ box-sizing: content-box;+ position: relative;+ z-index: 1;+ }++ &[data-placement='gap'][data-axis='x'] {+ height: 100%;+ width: 0;+ margin: 0 -4px;+ padding: 0 4px;+ }++ &[data-placement='gap'][data-axis='y'] {+ width: 100%;+ height: 0;+ margin: -4px 0;+ padding: 4px 0;+ }}.bar {@@ -40,3 +99,35 @@.area:not([data-disabled]):hover > .bar {background-color: var(--t-font-color-tertiary);}++.area[data-edge] > .bar {+ block-size: 48px;+ inline-size: 4px;+ transition:+ background-color duration(fast),+ transform duration(fast);+}++.area[data-edge][data-axis='y'] > .bar {+ block-size: 3px;+ inline-size: 48px;+}++.area[data-edge]:not([data-disabled]):is(+ :hover,+ :focus-visible,+ [data-resizing]+ )+ > .bar {+ background-color: var(--t-border-color-strong);+ transform: scaleY(1.2);+}++.area[data-edge][data-axis='y']:not([data-disabled]):is(+ :hover,+ :focus-visible,+ [data-resizing]+ )+ > .bar {+ transform: scaleX(1.2);+}diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.tsxindex 22dc6dfa8ee..10b35120702 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.tsx+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/ResizeHandle.tsx@@ -3,27 +3,48 @@ import { useRender } from '@base-ui/react/use-render';import { clamp } from '@base-ui/utils/clamp';import { useControlled } from '@base-ui/utils/useControlled';import { clsx } from 'clsx';+import { useState } from 'react';++import { isDefined } from '@ui/utilities/utils/isDefined';import { RESIZE_HANDLE_DEFAULTS } from './internal/ResizeHandleDefaults.constant';+import { RESIZE_HANDLE_EDGES } from './internal/ResizeHandleEdges.constant';import { useResizeHandleInteraction } from './internal/useResizeHandleInteraction';import styles from './ResizeHandle.module.scss';import { type ResizeHandleProps } from './types/ResizeHandleProps';export const ResizeHandle = ({- axis = 'y',+ axis: requestedAxis = 'y',+ direction,+ edge,+ placement = isDefined(edge) ? 'edge' : 'inline',+ scale = 1,+ dragThreshold = isDefined(edge)+ ? RESIZE_HANDLE_DEFAULTS.edgeDragThreshold+ : RESIZE_HANDLE_DEFAULTS.dragThreshold,value: controlledValue,defaultValue = RESIZE_HANDLE_DEFAULTS.value,onValueChange,+ onValueCommitted,+ onResizeStart,+ onResizeEnd,+ onActivate,min = RESIZE_HANDLE_DEFAULTS.min,max = RESIZE_HANDLE_DEFAULTS.max,step = RESIZE_HANDLE_DEFAULTS.step,disabled = false,className,- children,+ children = placement === 'gap' ? null : <div className={styles.bar} />,render,ref,...props}: ResizeHandleProps) => {+ const edgeConfiguration = isDefined(edge)+ ? RESIZE_HANDLE_EDGES[edge]+ : undefined;+ const axis = edgeConfiguration?.axis ?? requestedAxis;+ const resolvedDirection = edgeConfiguration?.direction ?? direction;+ const [isResizing, setIsResizing] = useState(false);const [value, setValue] = useControlled({controlled: controlledValue,default: defaultValue,@@ -31,15 +52,26 @@ export const ResizeHandle = ({});const boundedValue = clamp(value, min, max);const handleValueChange = (nextValue: number) => {- if (nextValue === boundedValue) {- return;- }-setValue(nextValue);onValueChange?.(nextValue);};+ const handleResizeStart = (nextValue: number) => {+ setIsResizing(true);+ onResizeStart?.(nextValue);+ };+ const handleResizeEnd = (details: { cancelled: boolean; value: number }) => {+ setIsResizing(false);+ onResizeEnd?.(details);+ };const interactionProps = useResizeHandleInteraction({axis,+ direction: resolvedDirection,+ scale,+ dragThreshold,+ onValueCommitted,+ onResizeStart: handleResizeStart,+ onResizeEnd: handleResizeEnd,+ onActivate,value: boundedValue,onValueChange: handleValueChange,min,@@ -51,7 +83,7 @@ export const ResizeHandle = ({return useRender({render,ref,- state: { axis, disabled },+ state: { axis, edge, placement, disabled, resizing: isResizing },props: mergeProps<'div'>(interactionProps, props, {role: 'separator',tabIndex: disabled ? -1 : (props.tabIndex ?? 0),@@ -61,8 +93,11 @@ export const ResizeHandle = ({'aria-valuemax': max,'aria-valuenow': boundedValue,'aria-disabled': disabled || undefined,+ 'aria-keyshortcuts':+ props['aria-keyshortcuts'] ??+ (isDefined(onActivate) && !disabled ? 'Enter Space' : undefined),className: clsx(styles.area, className),- children: children ?? <div className={styles.bar} />,+ children,}),});};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ControlledResizeHandlePanel.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ControlledResizeHandlePanel.tsxnew file mode 100644index 00000000000..4ab4f152fdb--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ControlledResizeHandlePanel.tsx@@ -0,0 +1,46 @@+import { useState } from 'react';++import { Button } from '@ui/primitives/input/Button/Button';+import { Text } from '@ui/primitives/typography/Text/Text';++import { RESIZE_HANDLE_DEFAULTS } from '../internal/ResizeHandleDefaults.constant';+import { ResizeHandle } from '../ResizeHandle';+import { type ResizeHandleProps } from '../types/ResizeHandleProps';++export const ControlledResizeHandlePanel = ({+ onValueChange,+ onValueCommitted,+ ...props+}: ResizeHandleProps) => {+ const initialSize =+ props.value ?? props.defaultValue ?? RESIZE_HANDLE_DEFAULTS.value;+ const [size, setSize] = useState(initialSize);+ const [liveSize, setLiveSize] = useState(initialSize);++ return (+ <>+ <ResizeHandle+ {...props}+ value={liveSize}+ onValueChange={(nextSize) => {+ setLiveSize(nextSize);+ onValueChange?.(nextSize);+ }}+ onValueCommitted={(nextSize) => {+ setSize(nextSize);+ onValueCommitted?.(nextSize);+ }}+ />+ <Text>Live value: {liveSize}</Text>+ <Text>Saved value: {size}</Text>+ <Button+ onClick={() => {+ setSize(240);+ setLiveSize(240);+ }}+ >+ Restore saved size+ </Button>+ </>+ );+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/DisablingResizeHandle.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/DisablingResizeHandle.tsxnew file mode 100644index 00000000000..133f242ad8a--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/DisablingResizeHandle.tsx@@ -0,0 +1,17 @@+import { useState } from 'react';++import { Button } from '@ui/primitives/input/Button/Button';++import { ResizeHandle } from '../ResizeHandle';+import { type ResizeHandleProps } from '../types/ResizeHandleProps';++export const DisablingResizeHandle = (props: ResizeHandleProps) => {+ const [disabled, setDisabled] = useState(false);++ return (+ <>+ <ResizeHandle {...props} disabled={disabled} />+ <Button onClick={() => setDisabled(true)}>Disable resizing</Button>+ </>+ );+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.interactions.stories.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.interactions.stories.tsxindex 6f9c416bc77..63859bf720e 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.interactions.stories.tsx+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.interactions.stories.tsx@@ -2,9 +2,11 @@ import { DirectionProvider } from '@base-ui/react/direction-provider';import { type Meta, type StoryObj } from '@storybook/react-vite';import { expect, fireEvent, fn, userEvent, within } from 'storybook/test';+import { Button } from '@ui/primitives/input/Button/Button';import { ComponentDecorator } from '@ui/testing';import { ResizeHandle } from '../ResizeHandle';+import { type ResizeHandleProps } from '../types/ResizeHandleProps';import { ControlledResizeHandle } from './ControlledResizeHandle';import { withMockPointerCapture } from './withMockPointerCapture';@@ -13,7 +15,7 @@ const meta = {title: 'UI/Layout/ResizeHandle/Interactions',component: ResizeHandle,decorators: [ComponentDecorator],- args: { onValueChange: fn() },+ args: { onValueChange: fn(), onValueCommitted: fn(), onResizeEnd: fn() },} satisfies Meta<typeof ResizeHandle>;export default meta;@@ -29,6 +31,8 @@ export const Keyboard: Story = {await userEvent.keyboard('{ArrowDown}{ArrowDown}{ArrowDown}');await expect(handle).toHaveAttribute('aria-valuenow', '120');await expect(args.onValueChange).toHaveBeenCalledTimes(2);+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(2);+ await expect(args.onValueCommitted).toHaveBeenLastCalledWith(120);await expect(args.onValueChange).toHaveBeenNthCalledWith(1, 115);await expect(args.onValueChange).toHaveBeenNthCalledWith(2, 120);@@ -41,6 +45,72 @@ export const Keyboard: Story = {},};+export const ModifiedKeys: Story = {+ args: { onActivate: fn() },+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');++ handle.focus();+ await userEvent.keyboard(+ '{Alt>}{ArrowDown}{/Alt}{Control>}{Home}{/Control}{Meta>}{Enter}{/Meta}',+ );+ await expect(handle).toHaveAttribute('aria-valuenow', '150');+ await expect(args.onValueChange).not.toHaveBeenCalled();+ await expect(args.onActivate).not.toHaveBeenCalled();++ await userEvent.keyboard('{ArrowDown}');+ await expect(handle).toHaveAttribute('aria-valuenow', '160');+ },+};++export const PointerPressKeepsFocus: Story = {+ args: { axis: 'x', defaultValue: 150, min: 100, max: 220 },+ render: (args) => (+ <>+ <Button>Notes</Button>+ <ResizeHandle {...args} />+ </>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const notesButton = canvas.getByRole('button', { name: 'Notes' });+ const handle = canvas.getByRole('separator');+ const pointer = userEvent.setup();+ const handleDocumentMouseDown = fn();+ const ownerDocument = canvasElement.ownerDocument;++ ownerDocument.addEventListener('mousedown', handleDocumentMouseDown, true);+ notesButton.focus();++ try {+ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 20 },+ });+ await pointer.pointer({ target: handle, coords: { x: 60 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ },+ });+ await expect(handle).toHaveAttribute('aria-valuenow', '190');+ await expect(notesButton).toHaveFocus();+ await expect(handleDocumentMouseDown).toHaveBeenCalledTimes(1);++ await userEvent.keyboard('{ArrowRight}');+ await expect(handle).toHaveAttribute('aria-valuenow', '190');+ } finally {+ ownerDocument.removeEventListener(+ 'mousedown',+ handleDocumentMouseDown,+ true,+ );+ }+ },+};+export const Controlled: Story = {args: { axis: 'x' },render: (args) => <ControlledResizeHandle {...args} />,@@ -78,7 +148,7 @@ export const PointerDrag: Story = {});await pointer.pointer({ target: handle, coords: { x: 60, y: 900 } });await expect(handle.setPointerCapture).toHaveBeenCalledWith(1);- await expect(handle).toHaveFocus();+ await expect(handle).not.toHaveFocus();await expect(handle).toHaveAttribute('aria-valuenow', '190');await fireEvent.pointerMove(handle, { pointerId: 2, clientX: 100 });@@ -95,13 +165,16 @@ export const PointerDrag: Story = {const playPointerEnd = async ({canvasElement,+ args,eventName,}: {canvasElement: HTMLElement;+ args: ResizeHandleProps;eventName: 'pointerUp' | 'pointerCancel' | 'lostPointerCapture';}) => {const handle = within(canvasElement).getByRole('separator');const pointer = userEvent.setup();+ const finalValue = eventName === 'pointerUp' ? 200 : 150;await withMockPointerCapture({handle,@@ -112,10 +185,18 @@ const playPointerEnd = async ({coords: { y: 10 },});await pointer.pointer({ target: handle, coords: { y: 60 } });- await fireEvent[eventName](handle, { pointerId: 1 });+ await fireEvent[eventName](handle, { pointerId: 1, clientY: 60 });await pointer.pointer({ target: handle, coords: { y: 100 } });- await expect(handle).toHaveAttribute('aria-valuenow', '200');+ await expect(handle).toHaveAttribute('aria-valuenow', `${finalValue}`);await expect(handle.releasePointerCapture).toHaveBeenCalledWith(1);+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(+ eventName === 'pointerUp' ? 1 : 0,+ );+ await expect(args.onResizeEnd).toHaveBeenCalledTimes(1);+ await expect(args.onResizeEnd).toHaveBeenCalledWith({+ cancelled: eventName !== 'pointerUp',+ value: finalValue,+ });await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });await pointer.pointer({@@ -124,25 +205,28 @@ const playPointerEnd = async ({coords: { y: 60 },});await pointer.pointer({ target: handle, coords: { y: 70 } });- await expect(handle).toHaveAttribute('aria-valuenow', '210');+ await expect(handle).toHaveAttribute(+ 'aria-valuenow',+ `${finalValue + 10}`,+ );await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });},});};export const PointerRelease: Story = {- play: ({ canvasElement }) =>- playPointerEnd({ canvasElement, eventName: 'pointerUp' }),+ play: ({ canvasElement, args }) =>+ playPointerEnd({ canvasElement, args, eventName: 'pointerUp' }),};export const PointerCancel: Story = {- play: ({ canvasElement }) =>- playPointerEnd({ canvasElement, eventName: 'pointerCancel' }),+ play: ({ canvasElement, args }) =>+ playPointerEnd({ canvasElement, args, eventName: 'pointerCancel' }),};export const LostPointerCapture: Story = {- play: ({ canvasElement }) =>- playPointerEnd({ canvasElement, eventName: 'lostPointerCapture' }),+ play: ({ canvasElement, args }) =>+ playPointerEnd({ canvasElement, args, eventName: 'lostPointerCapture' }),};export const Disabled: Story = {diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.lifecycle.stories.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.lifecycle.stories.tsxnew file mode 100644index 00000000000..ad9a3e4c9e2--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.lifecycle.stories.tsx@@ -0,0 +1,258 @@+import { DirectionProvider } from '@base-ui/react/direction-provider';+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, fireEvent, fn, userEvent, within } from 'storybook/test';++import { ComponentDecorator } from '@ui/testing';++import { ResizeHandle } from '../ResizeHandle';++import { DisablingResizeHandle } from './DisablingResizeHandle';+import { withMockPointerCapture } from './withMockPointerCapture';++const meta = {+ title: 'UI/Layout/ResizeHandle/Lifecycle',+ component: ResizeHandle,+ decorators: [ComponentDecorator],+ args: {+ axis: 'x',+ defaultValue: 150,+ min: 100,+ max: 200,+ dragThreshold: 4,+ onValueChange: fn(),+ onValueCommitted: fn(),+ onResizeStart: fn(),+ onResizeEnd: fn(),+ onActivate: fn(),+ },+} satisfies Meta<typeof ResizeHandle>;++export default meta;+type Story = StoryObj<typeof meta>;++export const ClickAndDrag: Story = {+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100 },+ });+ await pointer.pointer({ target: handle, coords: { x: 103 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '150');+ await expect(args.onResizeStart).not.toHaveBeenCalled();+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.onActivate).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(handle).not.toHaveFocus();++ handle.focus();+ await userEvent.keyboard('{Enter} ');+ await expect(args.onActivate).toHaveBeenCalledTimes(3);+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100 },+ });+ await pointer.pointer({ target: handle, coords: { x: 120 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '170');+ await expect(args.onResizeStart).toHaveBeenCalledTimes(1);+ await expect(args.onResizeStart).toHaveBeenCalledWith(170);+ await pointer.pointer({ target: handle, coords: { x: 125 } });+ await userEvent.keyboard('{ArrowRight}{Enter}');+ await expect(handle).toHaveAttribute('aria-valuenow', '175');+ await expect(args.onActivate).toHaveBeenCalledTimes(3);+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await fireEvent.pointerUp(handle, { pointerId: 1, clientX: 140 });+ await fireEvent.click(handle, { detail: 1 });+ await expect(handle).toHaveAttribute('aria-valuenow', '190');+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(190);+ await expect(args.onResizeEnd).toHaveBeenCalledTimes(1);+ await expect(args.onResizeEnd).toHaveBeenCalledWith({+ cancelled: false,+ value: 190,+ });+ await expect(args.onActivate).toHaveBeenCalledTimes(3);+ },+ });+ },+};++export const ReleaseMovement: Story = {+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');++ await withMockPointerCapture({+ handle,+ run: async () => {+ await fireEvent.pointerDown(handle, {+ pointerId: 1,+ button: 0,+ clientX: 100,+ });+ await fireEvent.pointerUp(handle, { pointerId: 1, clientX: 300 });+ await expect(handle).toHaveAttribute('aria-valuenow', '200');+ await expect(args.onResizeStart).toHaveBeenCalledTimes(1);+ await expect(args.onResizeStart).toHaveBeenCalledWith(200);+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(200);+ await expect(args.onResizeEnd).toHaveBeenCalledTimes(1);+ await expect(args.onResizeEnd).toHaveBeenCalledWith({+ cancelled: false,+ value: 200,+ });+ },+ });+ },+};++export const ScaledPhysicalDirection: Story = {+ args: { direction: 'normal', scale: fn(() => 2) },+ decorators: [+ (Story) => (+ <DirectionProvider direction="rtl">+ <Story />+ </DirectionProvider>+ ),+ ],+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100 },+ });+ await pointer.pointer({ target: handle, coords: { x: 160 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '180');+ await pointer.pointer({ target: handle, coords: { x: 240 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '200');+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.scale).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(200);+ handle.focus();+ await userEvent.keyboard('{ArrowLeft}');+ await expect(handle).toHaveAttribute('aria-valuenow', '190');+ await expect(args.onValueCommitted).toHaveBeenLastCalledWith(190);+ },+ });+ },+};++export const ReverseVertical: Story = {+ args: { axis: 'y', direction: 'reverse' },+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { y: 100 },+ });+ await pointer.pointer({ target: handle, coords: { y: 70 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '180');+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ handle.focus();+ await userEvent.keyboard('{ArrowDown}');+ await expect(handle).toHaveAttribute('aria-valuenow', '170');+ await expect(args.onValueCommitted).toHaveBeenLastCalledWith(170);+ },+ });+ },+};++export const EscapeCancellation: Story = {+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();+ const handleDocumentKeyDown = fn();+ const ownerDocument = canvasElement.ownerDocument;++ ownerDocument.addEventListener('keydown', handleDocumentKeyDown);++ try {+ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100 },+ });+ await pointer.pointer({ target: handle, coords: { x: 140 } });+ await expect(handle).not.toHaveFocus();+ await userEvent.keyboard('{Escape}');+ await expect(args.onResizeEnd).toHaveBeenCalledTimes(1);+ await expect(args.onResizeEnd).toHaveBeenCalledWith({+ cancelled: true,+ value: 150,+ });+ await expect(handleDocumentKeyDown).not.toHaveBeenCalled();+ await expect(handle.releasePointerCapture).toHaveBeenCalledWith(1);+ await pointer.pointer({ target: handle, coords: { x: 180 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(handle).toHaveAttribute('aria-valuenow', '150');+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(args.onActivate).not.toHaveBeenCalled();+ await fireEvent.click(handle, { detail: 0 });+ await expect(args.onActivate).toHaveBeenCalledTimes(1);+ },+ });++ await userEvent.keyboard('{Escape}');+ await expect(handleDocumentKeyDown).toHaveBeenCalledTimes(1);+ } finally {+ ownerDocument.removeEventListener('keydown', handleDocumentKeyDown);+ }+ },+};++export const DisabledDuringDrag: Story = {+ render: (args) => <DisablingResizeHandle {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const handle = canvas.getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100 },+ });+ await pointer.pointer({ target: handle, coords: { x: 140 } });+ await fireEvent.click(+ canvas.getByRole('button', { name: 'Disable resizing' }),+ );+ await expect(handle).toHaveAttribute('aria-disabled', 'true');+ await pointer.pointer({ target: handle, coords: { x: 180 } });+ await expect(args.onResizeEnd).toHaveBeenCalledTimes(1);+ await expect(args.onResizeEnd).toHaveBeenCalledWith({+ cancelled: true,+ value: 150,+ });+ await expect(handle.releasePointerCapture).toHaveBeenCalledWith(1);+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(args.onActivate).not.toHaveBeenCalled();+ },+ });+ },+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.panels.interactions.stories.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.panels.interactions.stories.tsxnew file mode 100644index 00000000000..70a0118e5e9--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.panels.interactions.stories.tsx@@ -0,0 +1,476 @@+import { DirectionProvider } from '@base-ui/react/direction-provider';+import { type Meta, type StoryObj } from '@storybook/react-vite';+import {+ expect,+ fireEvent,+ fn,+ userEvent,+ waitFor,+ within,+} from 'storybook/test';++import { withMockPointerCapture } from '@ui/primitives/layout/ResizeHandle/__stories__/withMockPointerCapture';+import { ComponentDecorator } from '@ui/testing';++import { ResizeHandle } from '../ResizeHandle';++import { ControlledResizeHandlePanel } from './ControlledResizeHandlePanel';+import { playCancelledResize } from './playCancelledResize';+import { ResizeHandlePanelDemo } from './ResizeHandlePanelDemo';+import { UnmountingResizeHandle } from './UnmountingResizeHandle';++const meta = {+ id: 'ui-layout-resizehandle-panels-interactions',+ title: 'UI/Layout/ResizeHandle/Panels/Interactions',+ component: ResizeHandle,+ decorators: [ComponentDecorator],+ render: (args) => <ControlledResizeHandlePanel {...args} />,+ args: {+ edge: 'right',+ value: 200,+ min: 100,+ max: 300,+ style: { position: 'relative', width: 16, height: 100 },+ onValueChange: fn(),+ onValueCommitted: fn(),+ onResizeStart: fn(),+ onResizeEnd: fn(),+ onActivate: fn(),+ },+} satisfies Meta<typeof ResizeHandle>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Keyboard: Story = {+ args: { step: 30 },+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');++ await userEvent.tab();+ await expect(handle).toHaveFocus();+ await userEvent.keyboard('{ArrowRight}');+ await expect(handle).toHaveAttribute('aria-valuenow', '230');+ await expect(args.onValueChange).toHaveBeenLastCalledWith(230);+ await expect(args.onValueCommitted).toHaveBeenLastCalledWith(230);+ await userEvent.keyboard('{End}{ArrowRight}');+ await expect(handle).toHaveAttribute('aria-valuenow', '300');+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(2);+ await userEvent.keyboard('{Home}{ArrowLeft}{ArrowDown}');+ await expect(handle).toHaveAttribute('aria-valuenow', '100');+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(3);+ await expect(args.onResizeStart).not.toHaveBeenCalled();+ await expect(args.onActivate).not.toHaveBeenCalled();+ },+};++export const PhysicalEdges: Story = {+ decorators: [+ (Story) => (+ <DirectionProvider direction="rtl">+ <Story />+ </DirectionProvider>+ ),+ ],+ render: (args) => (+ <>+ <ControlledResizeHandlePanel+ {...args}+ axis={undefined}+ direction={undefined}+ edge="left"+ aria-label="Left edge"+ />+ <ControlledResizeHandlePanel+ {...args}+ axis={undefined}+ direction={undefined}+ edge="right"+ aria-label="Right edge"+ />+ <ControlledResizeHandlePanel+ {...args}+ axis={undefined}+ direction={undefined}+ edge="top"+ aria-label="Top edge"+ />+ <ControlledResizeHandlePanel+ {...args}+ axis={undefined}+ direction={undefined}+ edge="bottom"+ aria-label="Bottom edge"+ />+ </>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const cases = [+ {+ name: 'Left edge',+ key: '{ArrowLeft}',+ x: -20,+ y: 0,+ orientation: 'vertical',+ },+ {+ name: 'Right edge',+ key: '{ArrowRight}',+ x: 20,+ y: 0,+ orientation: 'vertical',+ },+ {+ name: 'Top edge',+ key: '{ArrowUp}',+ x: 0,+ y: -20,+ orientation: 'horizontal',+ },+ {+ name: 'Bottom edge',+ key: '{ArrowDown}',+ x: 0,+ y: 20,+ orientation: 'horizontal',+ },+ ];++ for (const { name, key, x, y, orientation } of cases) {+ const handle = canvas.getByRole('separator', { name });+ const pointer = userEvent.setup();++ handle.focus();+ await userEvent.keyboard(key);+ await expect(handle).toHaveAttribute('aria-valuenow', '210');+ await expect(handle).toHaveAttribute('aria-orientation', orientation);+ await expect(getComputedStyle(handle).cursor).toBe(+ orientation === 'vertical' ? 'col-resize' : 'row-resize',+ );+ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 100 },+ });+ await pointer.pointer({+ target: handle,+ coords: { x: 100 + x, y: 100 + y },+ });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(handle).toHaveAttribute('aria-valuenow', '230');+ },+ });+ }+ },+};++export const ControlledZoomAndLimits: Story = {+ args: { scale: () => 2 },+ render: (args) => <ControlledResizeHandlePanel {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const handle = canvas.getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 200, y: 900 } });+ await expect(handle.setPointerCapture).toHaveBeenCalledWith(1);+ await expect(handle).not.toHaveFocus();+ await expect(handle).toHaveAttribute('aria-valuenow', '250');+ await expect(canvas.getByText('Live value: 250')).toBeVisible();+ await expect(canvas.getByText('Saved value: 200')).toBeVisible();+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(args.onResizeStart).toHaveBeenCalledTimes(1);+ await expect(args.onResizeStart).toHaveBeenCalledWith(250);+ await fireEvent.pointerMove(handle, { pointerId: 2, clientX: 0 });+ await expect(handle).toHaveAttribute('aria-valuenow', '250');+ await pointer.pointer({ target: handle, coords: { x: 1000 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '300');+ await pointer.pointer({ target: handle, coords: { x: -1000 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '100');+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(100);+ await expect(args.onResizeEnd).toHaveBeenLastCalledWith({+ cancelled: false,+ value: 100,+ });+ await expect(args.onActivate).not.toHaveBeenCalled();+ await expect(canvas.getByText('Saved value: 100')).toBeVisible();+ },+ });++ await userEvent.click(+ canvas.getByRole('button', { name: 'Restore saved size' }),+ );+ await expect(handle).toHaveAttribute('aria-valuenow', '240');+ handle.focus();+ await userEvent.keyboard('{ArrowLeft}');+ await expect(canvas.getByText('Saved value: 230')).toBeVisible();+ },+};++export const FastPointerMoves: Story = {+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');++ await withMockPointerCapture({+ handle,+ run: async () => {+ await fireEvent.pointerDown(handle, {+ pointerId: 1,+ button: 0,+ clientX: 100,+ });+ await fireEvent.pointerMove(handle, { pointerId: 1, clientX: 140 });+ await waitFor(() =>+ expect(handle).toHaveAttribute('aria-valuenow', '240'),+ );++ for (const [type, clientX] of [+ ['pointermove', 170],+ ['pointermove', 140],+ ['pointerup', 140],+ ] as const) {+ handle.dispatchEvent(+ new PointerEvent(type, { bubbles: true, pointerId: 1, clientX }),+ );+ }++ await expect(args.onValueChange).toHaveBeenLastCalledWith(240);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(240);+ await waitFor(() =>+ expect(handle).toHaveAttribute('aria-valuenow', '240'),+ );+ },+ });+ },+};++export const PointerCancel: Story = {+ render: (args) => <ControlledResizeHandlePanel {...args} />,+ play: ({ canvasElement, args }) =>+ playCancelledResize({+ canvasElement,+ args,+ cancellation: 'pointerCancel',+ }),+};++export const LostPointerCapture: Story = {+ play: ({ canvasElement, args }) =>+ playCancelledResize({+ canvasElement,+ args,+ cancellation: 'lostPointerCapture',+ }),+};++export const Escape: Story = {+ play: ({ canvasElement, args }) =>+ playCancelledResize({ canvasElement, args, cancellation: 'Escape' }),+};++export const CollapseAndDrag: Story = {+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 104, y: 10 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.onActivate).toHaveBeenCalledTimes(1);+ await expect(args.onValueChange).not.toHaveBeenCalled();+ await expect(args.onValueCommitted).not.toHaveBeenCalled();++ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 106, y: 10 } });+ await pointer.pointer({ target: handle, coords: { x: 100, y: 10 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.onActivate).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(200);+ await expect(handle).toHaveAttribute('aria-valuenow', '200');+ },+ });++ handle.focus();+ await userEvent.keyboard('{Enter} ');+ await expect(args.onActivate).toHaveBeenCalledTimes(3);+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(handle).toHaveFocus();+ },+};++export const DragPinnedAtBound: Story = {+ args: { value: 300 },+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 160, y: 10 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(handle).toHaveAttribute('aria-valuenow', '300');+ await expect(args.onResizeStart).toHaveBeenCalledWith(300);+ await expect(args.onActivate).not.toHaveBeenCalled();+ },+ });+ },+};++export const CollapseMovesFocus: Story = {+ render: () => (+ <ResizeHandlePanelDemo edge="right" value={220} min={140} max={360} />+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await userEvent.tab();+ await expect(+ canvas.getByRole('separator', { name: 'Resize notes' }),+ ).toHaveFocus();+ await userEvent.keyboard('{Enter}');+ await expect(+ canvas.getByRole('button', { name: 'Show notes' }),+ ).toHaveFocus();+ await userEvent.keyboard('{Enter}');+ await expect(+ canvas.getByRole('separator', { name: 'Resize notes' }),+ ).toHaveFocus();+ },+};++export const IndependentInstances: Story = {+ render: (args) => (+ <>+ <ControlledResizeHandlePanel {...args} aria-label="Notes" />+ <ControlledResizeHandlePanel+ {...args}+ aria-label="Activity"+ placement="gap"+ style={{ width: 12, height: 100 }}+ />+ </>+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const notes = canvas.getByRole('separator', { name: 'Notes' });+ const activity = canvas.getByRole('separator', { name: 'Activity' });++ notes.focus();+ await userEvent.keyboard('{ArrowRight}');+ await expect(notes).toHaveAttribute('aria-valuenow', '210');+ await expect(activity).toHaveAttribute('aria-valuenow', '200');+ activity.focus();+ await userEvent.keyboard('{ArrowLeft}');+ await expect(activity).toHaveAttribute('aria-valuenow', '190');+ await expect(notes).toHaveAttribute('aria-valuenow', '210');+ },+};++export const Disabled: Story = {+ args: { disabled: true },+ play: async ({ canvasElement, args }) => {+ const handle = within(canvasElement).getByRole('separator');++ await expect(handle).toHaveAttribute('aria-disabled', 'true');+ await expect(handle).toHaveAttribute('tabindex', '-1');+ await expect(handle).not.toHaveAttribute('aria-keyshortcuts');+ await userEvent.tab();+ await expect(handle).not.toHaveFocus();+ await userEvent.click(handle);+ await expect(handle).not.toHaveFocus();+ handle.focus();+ await userEvent.keyboard('{ArrowRight}{Enter} ');+ await expect(handle).toHaveAttribute('aria-valuenow', '200');+ await expect(args.onValueChange).not.toHaveBeenCalled();+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(args.onActivate).not.toHaveBeenCalled();+ },+};++export const UnmountWhileDragging: Story = {+ render: (args) => <UnmountingResizeHandle {...args} />,+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const handle = canvas.getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 150, y: 10 } });+ await expect(canvas.getByText('Live value: 250')).toBeVisible();+ canvas.getByRole('button', { name: 'Hide panel' }).focus();+ await userEvent.keyboard('{Enter}');+ await expect(canvas.queryByRole('separator')).not.toBeInTheDocument();+ await expect(canvas.getByText('Live value: 200')).toBeVisible();+ await expect(args.onResizeEnd).toHaveBeenCalledTimes(1);+ await expect(args.onResizeEnd).toHaveBeenCalledWith({+ cancelled: true,+ value: 200,+ });+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(args.onActivate).not.toHaveBeenCalled();+ await expect(handle.releasePointerCapture).toHaveBeenCalledWith(1);+ },+ });+ },+};++export const GapLayout: Story = {+ render: () => (+ <ResizeHandlePanelDemo+ edge="top"+ placement="gap"+ value={220}+ min={140}+ max={360}+ />+ ),+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const activity = canvas.getByRole('region', { name: 'Activity' });+ const notes = canvas.getByRole('region', { name: 'Notes' });++ await expect(+ notes.getBoundingClientRect().top -+ activity.getBoundingClientRect().bottom,+ ).toBe(12);+ },+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.panels.stories.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.panels.stories.tsxnew file mode 100644index 00000000000..e5b557a72e6--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandle.panels.stories.tsx@@ -0,0 +1,41 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';++import { ComponentDecorator } from '@ui/testing';++import { ResizeHandle } from '../ResizeHandle';++import { ResizeHandlePanelDemo } from './ResizeHandlePanelDemo';++const meta = {+ id: 'ui-layout-resizehandle-panels',+ title: 'UI/Layout/ResizeHandle/Panels',+ component: ResizeHandle,+ decorators: [ComponentDecorator],+ args: { edge: 'right', value: 220, min: 140, max: 360 },+ render: (args) => <ResizeHandlePanelDemo key={args.value} {...args} />,+} satisfies Meta<typeof ResizeHandle>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Documentation: Story = {};++export const LeftEdge: Story = {+ args: { edge: 'left' },+};++export const TopEdge: Story = {+ args: { edge: 'top' },+};++export const BottomEdge: Story = {+ args: { edge: 'bottom' },+};++export const Gap: Story = {+ args: { edge: 'top', placement: 'gap' },+};++export const Dark: Story = {+ globals: { colorScheme: 'dark' },+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandlePanelDemo.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandlePanelDemo.tsxnew file mode 100644index 00000000000..a5ceb5c0269--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/ResizeHandlePanelDemo.tsx@@ -0,0 +1,111 @@+import { useMergedRefs } from '@base-ui/utils/useMergedRefs';+import { useCallback, useId, useRef, useState } from 'react';++import { Button } from '@ui/primitives/input/Button/Button';+import { Card } from '@ui/primitives/surfaces/Card/Card';+import { Text } from '@ui/primitives/typography/Text/Text';++import { RESIZE_HANDLE_DEFAULTS } from '../internal/ResizeHandleDefaults.constant';+import { ResizeHandle } from '../ResizeHandle';+import { type ResizeHandleProps } from '../types/ResizeHandleProps';++export const ResizeHandlePanelDemo = ({+ edge = 'right',+ placement = 'edge',+ min,+ max,+ value: initialSize = RESIZE_HANDLE_DEFAULTS.value,+}: Pick<ResizeHandleProps, 'edge' | 'placement' | 'min' | 'max' | 'value'>) => {+ const regionId = useId();+ const separatorRef = useRef<HTMLDivElement>(null);+ const [size, setSize] = useState(initialSize);+ const [committedSize, setCommittedSize] = useState(initialSize);+ const [isCollapsed, setIsCollapsed] = useState(false);+ const [shouldFocusOnMount, setShouldFocusOnMount] = useState(false);++ const focusOnMount = useCallback(+ (element: HTMLElement | null) => {+ if (shouldFocusOnMount) {+ element?.focus();+ }+ },+ [shouldFocusOnMount],+ );+ const mergedSeparatorRef = useMergedRefs(separatorRef, focusOnMount);++ const collapseNotes = () => {+ setShouldFocusOnMount(separatorRef.current === document.activeElement);+ setIsCollapsed(true);+ };++ const showNotes = () => {+ setShouldFocusOnMount(true);+ setIsCollapsed(false);+ };++ const isHorizontal = edge === 'left' || edge === 'right';+ const gapStyle = isHorizontal ? { width: 12 } : { height: 12 };+ const isBefore = edge === 'left' || edge === 'top';+ const adjacentPanel = (+ <Card.Root role="region" aria-label="Activity" style={{ padding: 24 }}>+ <Text>Activity</Text>+ </Card.Root>+ );+ const separator = (+ <ResizeHandle+ ref={mergedSeparatorRef}+ edge={edge}+ placement={placement}+ style={placement === 'gap' ? gapStyle : undefined}+ aria-label="Resize notes"+ aria-controls={regionId}+ value={size}+ min={min}+ max={max}+ onValueChange={setSize}+ onValueCommitted={setCommittedSize}+ onActivate={collapseNotes}+ />+ );++ if (isCollapsed) {+ return (+ <Button ref={focusOnMount} onClick={showNotes}>+ Show notes+ </Button>+ );+ }++ return (+ <div+ style={{+ display: 'flex',+ flexDirection: isHorizontal ? 'row' : 'column',+ width: isHorizontal ? 'auto' : 320,+ }}+ >+ {placement === 'gap' && isBefore && adjacentPanel}+ {placement === 'gap' && isBefore && separator}+ <Card.Root+ id={regionId}+ role="region"+ aria-label="Notes"+ style={{+ position: 'relative',+ overflow: 'visible',+ boxSizing: 'border-box',+ height: isHorizontal ? 180 : size,+ width: isHorizontal ? size : 320,+ padding: 24,+ }}+ >+ <Text>Notes</Text>+ <Text>{size} pixels</Text>+ <Text>Saved: {committedSize} pixels</Text>+ {placement === 'edge' && separator}+ </Card.Root>+ {placement === 'gap' && !isBefore && separator}+ {placement === 'gap' && !isBefore && adjacentPanel}+ </div>+ );+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/UnmountingResizeHandle.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/UnmountingResizeHandle.tsxnew file mode 100644index 00000000000..87df7470aa2--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/UnmountingResizeHandle.tsx@@ -0,0 +1,37 @@+import { useState } from 'react';++import { Button } from '@ui/primitives/input/Button/Button';+import { Text } from '@ui/primitives/typography/Text/Text';++import { RESIZE_HANDLE_DEFAULTS } from '../internal/ResizeHandleDefaults.constant';+import { ResizeHandle } from '../ResizeHandle';+import { type ResizeHandleProps } from '../types/ResizeHandleProps';++export const UnmountingResizeHandle = ({+ onValueChange,+ onValueCommitted,+ ...props+}: ResizeHandleProps) => {+ const [isVisible, setIsVisible] = useState(true);+ const [liveSize, setLiveSize] = useState(+ props.value ?? props.defaultValue ?? RESIZE_HANDLE_DEFAULTS.value,+ );++ return (+ <>+ {isVisible && (+ <ResizeHandle+ {...props}+ value={liveSize}+ onValueChange={(size) => {+ setLiveSize(size);+ onValueChange?.(size);+ }}+ onValueCommitted={onValueCommitted}+ />+ )}+ <Text>Live value: {liveSize}</Text>+ <Button onClick={() => setIsVisible(false)}>Hide panel</Button>+ </>+ );+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/playCancelledResize.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/playCancelledResize.tsnew file mode 100644index 00000000000..671699fcfdb--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__stories__/playCancelledResize.ts@@ -0,0 +1,60 @@+import { expect, fireEvent, userEvent, within } from 'storybook/test';++import { withMockPointerCapture } from '@ui/primitives/layout/ResizeHandle/__stories__/withMockPointerCapture';++import { type ResizeHandleProps } from '../types/ResizeHandleProps';++export const playCancelledResize = async ({+ canvasElement,+ args,+ cancellation,+}: {+ canvasElement: HTMLElement;+ args: ResizeHandleProps;+ cancellation: 'pointerCancel' | 'lostPointerCapture' | 'Escape';+}) => {+ const handle = within(canvasElement).getByRole('separator');+ const pointer = userEvent.setup();++ await withMockPointerCapture({+ handle,+ run: async () => {+ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 140, y: 10 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '240');+ await expect(args.onValueChange).toHaveBeenLastCalledWith(240);++ await (cancellation === 'Escape'+ ? userEvent.keyboard('{Escape}')+ : fireEvent[cancellation](handle, { pointerId: 1 }));++ await expect(handle).toHaveAttribute('aria-valuenow', '200');+ await expect(args.onValueChange).toHaveBeenLastCalledWith(200);+ await expect(args.onValueCommitted).not.toHaveBeenCalled();+ await expect(args.onResizeEnd).toHaveBeenLastCalledWith({+ cancelled: true,+ value: 200,+ });+ await expect(handle.releasePointerCapture).toHaveBeenCalledWith(1);+ await pointer.pointer({ target: handle, coords: { x: 190, y: 10 } });+ await expect(handle).toHaveAttribute('aria-valuenow', '200');+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(args.onActivate).not.toHaveBeenCalled();++ await pointer.pointer({+ target: handle,+ keys: '[MouseLeft>]',+ coords: { x: 100, y: 10 },+ });+ await pointer.pointer({ target: handle, coords: { x: 110, y: 10 } });+ await pointer.pointer({ target: handle, keys: '[/MouseLeft]' });+ await expect(handle).toHaveAttribute('aria-valuenow', '210');+ await expect(args.onValueCommitted).toHaveBeenCalledTimes(1);+ await expect(args.onValueCommitted).toHaveBeenCalledWith(210);+ },+ });+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__tests__/ResizeHandle.test.tsx b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__tests__/ResizeHandle.test.tsxindex ce7d86525f9..73f8fb53f03 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/__tests__/ResizeHandle.test.tsx+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/__tests__/ResizeHandle.test.tsx@@ -9,3 +9,24 @@ runComponentConformance({refInstanceOf: HTMLDivElement,ownClassName: styles.area,});++runComponentConformance({+ name: 'ResizeHandle edge',+ element: <ResizeHandle edge="right" value={200} min={100} max={300} />,+ refInstanceOf: HTMLDivElement,+});++runComponentConformance({+ name: 'ResizeHandle gap',+ element: (+ <ResizeHandle+ edge="top"+ value={200}+ placement="gap"+ style={{ height: 12 }}+ min={100}+ max={300}+ />+ ),+ refInstanceOf: HTMLDivElement,+});diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeGesture.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeGesture.tsnew file mode 100644index 00000000000..520c1c1f464--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeGesture.ts@@ -0,0 +1,12 @@+export type ResizeGesture = {+ pointerId: number;+ target: HTMLDivElement;+ axis: 'x' | 'y';+ startPosition: number;+ startValue: number;+ currentValue: number;+ multiplier: number;+ threshold: number;+ hasStarted: boolean;+ removeEscapeKeyListener: () => void;+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleDefaults.constant.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleDefaults.constant.tsindex aa09d9aec8e..1c77e8d840d 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleDefaults.constant.ts+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleDefaults.constant.ts@@ -3,4 +3,6 @@ export const RESIZE_HANDLE_DEFAULTS = {min: 50,max: 500,step: 10,+ dragThreshold: 0,+ edgeDragThreshold: 5,};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleEdges.constant.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleEdges.constant.tsnew file mode 100644index 00000000000..0dc558160b1--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/ResizeHandleEdges.constant.ts@@ -0,0 +1,6 @@+export const RESIZE_HANDLE_EDGES = {+ left: { axis: 'x', direction: 'reverse' },+ right: { axis: 'x', direction: 'normal' },+ top: { axis: 'y', direction: 'reverse' },+ bottom: { axis: 'y', direction: 'normal' },+} as const;diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandleInteraction.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandleInteraction.tsindex 5447f52f88e..c34dc5a83c5 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandleInteraction.ts+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandleInteraction.ts@@ -1,99 +1,98 @@import { useDirection } from '@base-ui/react/direction-provider';import { clamp } from '@base-ui/utils/clamp';-import { type KeyboardEvent, type PointerEvent, useRef } from 'react';+import { type KeyboardEvent } from 'react';import { isDefined } from '@ui/utilities/utils/isDefined';-type ResizeGesture = {- pointerId: number;- startPosition: number;- startValue: number;-};--type UseResizeHandleInteractionArgs = {- axis: 'x' | 'y';- value: number;- onValueChange: (value: number) => void;- min: number;- max: number;- step: number;- disabled: boolean;-};+import { type ResizeHandleProps } from '../types/ResizeHandleProps';++import { useResizeHandlePointerInteraction } from './useResizeHandlePointerInteraction';++type UseResizeHandleInteractionArgs = Required<+ Pick<+ ResizeHandleProps,+ 'axis' | 'value' | 'min' | 'max' | 'step' | 'disabled'+ >+> &+ Pick<+ ResizeHandleProps,+ | 'direction'+ | 'onValueCommitted'+ | 'onResizeStart'+ | 'onResizeEnd'+ | 'onActivate'+ > & {+ onValueChange: (value: number) => void;+ scale: number | (() => number);+ dragThreshold: number;+ };export const useResizeHandleInteraction = ({axis,+ direction,value,onValueChange,+ onValueCommitted,+ onResizeStart,+ onResizeEnd,+ onActivate,+ scale,+ dragThreshold,min,max,step,disabled,}: UseResizeHandleInteractionArgs) => {- const direction = useDirection();- const isHorizontalRtl = axis === 'x' && direction === 'rtl';- const gestureRef = useRef<ResizeGesture | null>(null);-- const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {- if (- disabled ||- event.defaultPrevented ||- event.button !== 0 ||- isDefined(gestureRef.current)- ) {- return;- }-- event.preventDefault();- event.currentTarget.focus?.();- event.currentTarget.setPointerCapture?.(event.pointerId);- gestureRef.current = {- pointerId: event.pointerId,- startPosition: axis === 'y' ? event.clientY : event.clientX,- startValue: value,- };- };+ const textDirection = useDirection();+ const isReversed = isDefined(direction)+ ? direction === 'reverse'+ : axis === 'x' && textDirection === 'rtl';+ const { isPointerActive, ...pointerInteractionProps } =+ useResizeHandlePointerInteraction({+ axis,+ isReversed,+ value,+ onValueChange,+ onValueCommitted,+ onResizeStart,+ onResizeEnd,+ onActivate,+ scale,+ dragThreshold,+ min,+ max,+ disabled,+ });- const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {- const gesture = gestureRef.current;+ const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {+ const hasModifierKey = event.altKey || event.ctrlKey || event.metaKey;if (- disabled ||event.defaultPrevented ||- !isDefined(gesture) ||- gesture.pointerId !== event.pointerId+ disabled ||+ hasModifierKey ||+ isPointerActive()) {return;}- const position = axis === 'y' ? event.clientY : event.clientX;- const delta =- (position - gesture.startPosition) * (isHorizontalRtl ? -1 : 1);- const nextValue = clamp(gesture.startValue + delta, min, max);-- onValueChange(nextValue);- };-- const handlePointerEnd = (event: PointerEvent<HTMLDivElement>) => {- if (gestureRef.current?.pointerId !== event.pointerId) {- return;- }+ const isActivationKey = event.key === 'Enter' || event.key === ' ';- gestureRef.current = null;+ if (isActivationKey && isDefined(onActivate)) {+ event.preventDefault();+ event.stopPropagation();- if (event.currentTarget.hasPointerCapture?.(event.pointerId)) {- event.currentTarget.releasePointerCapture?.(event.pointerId);- }- };+ if (!event.repeat) {+ onActivate();+ }- const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {- if (disabled || event.defaultPrevented) {return;}- const increaseKey =- axis === 'y' ? 'ArrowDown' : isHorizontalRtl ? 'ArrowLeft' : 'ArrowRight';- const decreaseKey =- axis === 'y' ? 'ArrowUp' : isHorizontalRtl ? 'ArrowRight' : 'ArrowLeft';+ const forwardKey = axis === 'y' ? 'ArrowDown' : 'ArrowRight';+ const backwardKey = axis === 'y' ? 'ArrowUp' : 'ArrowLeft';+ const increaseKey = isReversed ? backwardKey : forwardKey;+ const decreaseKey = isReversed ? forwardKey : backwardKey;const valueByKey = new Map([[increaseKey, value + step],[decreaseKey, value - step],@@ -108,15 +107,16 @@ export const useResizeHandleInteraction = ({event.preventDefault();event.stopPropagation();- onValueChange(clamp(nextValue, min, max));- };- return {- onPointerDown: handlePointerDown,- onPointerMove: handlePointerMove,- onPointerUp: handlePointerEnd,- onPointerCancel: handlePointerEnd,- onLostPointerCapture: handlePointerEnd,- onKeyDown: handleKeyDown,+ const boundedValue = clamp(nextValue, min, max);++ if (boundedValue === value) {+ return;+ }++ onValueChange(boundedValue);+ onValueCommitted?.(boundedValue);};++ return { ...pointerInteractionProps, onKeyDown: handleKeyDown };};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandlePointerInteraction.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandlePointerInteraction.tsnew file mode 100644index 00000000000..5f601889223--- /dev/null+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/internal/useResizeHandlePointerInteraction.ts@@ -0,0 +1,214 @@+import { clamp } from '@base-ui/utils/clamp';+import { useStableCallback } from '@base-ui/utils/useStableCallback';+import { isFunction } from '@sniptt/guards';+import { type MouseEvent, type PointerEvent, useEffect, useRef } from 'react';++import { isDefined } from '@ui/utilities/utils/isDefined';++import { type ResizeHandleProps } from '../types/ResizeHandleProps';++import { type ResizeGesture } from './ResizeGesture';++type UseResizeHandlePointerInteractionArgs = Required<+ Pick<ResizeHandleProps, 'axis' | 'value' | 'min' | 'max' | 'disabled'>+> &+ Pick<+ ResizeHandleProps,+ 'onValueCommitted' | 'onResizeStart' | 'onResizeEnd' | 'onActivate'+ > & {+ isReversed: boolean;+ onValueChange: (value: number) => void;+ scale: number | (() => number);+ dragThreshold: number;+ };++export const useResizeHandlePointerInteraction = ({+ axis,+ isReversed,+ value,+ onValueChange,+ onValueCommitted,+ onResizeStart,+ onResizeEnd,+ onActivate,+ scale,+ dragThreshold,+ min,+ max,+ disabled,+}: UseResizeHandlePointerInteractionArgs) => {+ const gestureRef = useRef<ResizeGesture | null>(null);+ const suppressActivationRef = useRef(false);++ const finishResize = useStableCallback((cancelled: boolean) => {+ const gesture = gestureRef.current;++ if (!isDefined(gesture)) {+ return;+ }++ gestureRef.current = null;+ gesture.removeEscapeKeyListener();+ suppressActivationRef.current = cancelled || gesture.hasStarted;++ if (gesture.target.hasPointerCapture?.(gesture.pointerId)) {+ gesture.target.releasePointerCapture?.(gesture.pointerId);+ }++ if (!gesture.hasStarted) {+ return;+ }++ const finalValue = cancelled+ ? clamp(gesture.startValue, min, max)+ : gesture.currentValue;++ if (cancelled) {+ onValueChange(finalValue);+ }++ if (!cancelled) {+ onValueCommitted?.(finalValue);+ }++ onResizeEnd?.({ cancelled, value: finalValue });+ });++ useEffect(+ () => () => {+ finishResize(true);+ },+ [finishResize],+ );++ const handleMouseDown = (event: MouseEvent<HTMLDivElement>) => {+ event.preventDefault();+ };++ const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {+ if (+ disabled ||+ event.defaultPrevented ||+ event.button !== 0 ||+ isDefined(gestureRef.current)+ ) {+ return;+ }++ const requestedScale = isFunction(scale) ? scale() : scale;+ const resolvedScale =+ Number.isFinite(requestedScale) && requestedScale > 0+ ? requestedScale+ : 1;+ const ownerWindow = event.currentTarget.ownerDocument?.defaultView;++ const handleEscapeKeyDown = (keyboardEvent: KeyboardEvent) => {+ if (keyboardEvent.key !== 'Escape') {+ return;+ }++ keyboardEvent.preventDefault();+ keyboardEvent.stopPropagation();+ finishResize(true);+ };++ event.currentTarget.setPointerCapture?.(event.pointerId);+ ownerWindow?.addEventListener('keydown', handleEscapeKeyDown, true);+ suppressActivationRef.current = false;+ gestureRef.current = {+ pointerId: event.pointerId,+ target: event.currentTarget,+ axis,+ startPosition: axis === 'y' ? event.clientY : event.clientX,+ startValue: value,+ currentValue: value,+ multiplier: (isReversed ? -1 : 1) / resolvedScale,+ threshold: Math.max(0, dragThreshold),+ hasStarted: false,+ removeEscapeKeyListener: () =>+ ownerWindow?.removeEventListener('keydown', handleEscapeKeyDown, true),+ };+ };++ const updateResize = (event: PointerEvent<HTMLDivElement>) => {+ const gesture = gestureRef.current;++ if (+ event.defaultPrevented ||+ !isDefined(gesture) ||+ gesture.pointerId !== event.pointerId+ ) {+ return;+ }++ if (disabled) {+ finishResize(true);+ return;+ }++ const position = gesture.axis === 'y' ? event.clientY : event.clientX;+ const delta = position - gesture.startPosition;+ const crossedThreshold = Math.abs(delta) > gesture.threshold;++ if (!gesture.hasStarted && !crossedThreshold) {+ return;+ }++ const nextValue = clamp(+ gesture.startValue + delta * gesture.multiplier,+ min,+ max,+ );++ if (gesture.hasStarted && nextValue === gesture.currentValue) {+ return;+ }++ gesture.currentValue = nextValue;++ if (!gesture.hasStarted) {+ gesture.hasStarted = true;+ onResizeStart?.(nextValue);+ }++ onValueChange(nextValue);+ };++ const handlePointerUp = (event: PointerEvent<HTMLDivElement>) => {+ if (gestureRef.current?.pointerId !== event.pointerId) {+ return;+ }++ updateResize(event);+ finishResize(disabled || event.defaultPrevented);+ };++ const handlePointerCancel = (event: PointerEvent<HTMLDivElement>) => {+ if (gestureRef.current?.pointerId === event.pointerId) {+ finishResize(true);+ }+ };++ const handleClick = (event: MouseEvent<HTMLDivElement>) => {+ const isDragClick = suppressActivationRef.current && event.detail > 0;++ suppressActivationRef.current = false;++ if (disabled || event.defaultPrevented || isDragClick) {+ return;+ }++ onActivate?.();+ };++ return {+ onMouseDown: handleMouseDown,+ onPointerDown: handlePointerDown,+ onPointerMove: updateResize,+ onPointerUp: handlePointerUp,+ onPointerCancel: handlePointerCancel,+ onLostPointerCapture: handlePointerCancel,+ onClick: handleClick,+ isPointerActive: () => isDefined(gestureRef.current),+ };+};diff --git a/packages/twenty-ui/src/primitives/layout/ResizeHandle/types/ResizeHandleProps.ts b/packages/twenty-ui/src/primitives/layout/ResizeHandle/types/ResizeHandleProps.tsindex e3c4c107830..6122874158c 100644--- a/packages/twenty-ui/src/primitives/layout/ResizeHandle/types/ResizeHandleProps.ts+++ b/packages/twenty-ui/src/primitives/layout/ResizeHandle/types/ResizeHandleProps.ts@@ -1,12 +1,32 @@import { type useRender } from '@base-ui/react/use-render';-export type ResizeHandleProps = useRender.ComponentProps<'div'> & {- axis?: 'x' | 'y';- value?: number;- defaultValue?: number;- onValueChange?: (value: number) => void;- min?: number;- max?: number;- step?: number;- disabled?: boolean;-};+type ResizeHandlePositionProps =+ | {+ edge: 'left' | 'right' | 'top' | 'bottom';+ placement?: 'inline' | 'edge' | 'gap';+ axis?: never;+ direction?: never;+ }+ | {+ edge?: never;+ placement?: 'inline' | 'gap';+ axis?: 'x' | 'y';+ direction?: 'normal' | 'reverse';+ };++export type ResizeHandleProps = useRender.ComponentProps<'div'> &+ ResizeHandlePositionProps & {+ scale?: number | (() => number);+ dragThreshold?: number;+ value?: number;+ defaultValue?: number;+ onValueChange?: (value: number) => void;+ onValueCommitted?: (value: number) => void;+ onResizeStart?: (value: number) => void;+ onResizeEnd?: (details: { cancelled: boolean; value: number }) => void;+ onActivate?: () => void;+ min?: number;+ max?: number;+ step?: number;+ disabled?: boolean;+ };