diff --git a/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutContainer/StudioResizableLayoutContainer.test.tsx b/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutContainer/StudioResizableLayoutContainer.test.tsx index b23bfd8f31e..b5421ab4033 100644 --- a/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutContainer/StudioResizableLayoutContainer.test.tsx +++ b/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutContainer/StudioResizableLayoutContainer.test.tsx @@ -5,14 +5,14 @@ import { fireEvent, render, screen } from '@testing-library/react'; import { StudioResizableLayoutElement } from '../StudioResizableLayoutElement/StudioResizableLayoutElement'; describe('StudioResizableLayoutContainer', () => { - it('should render just one handle with two elements', () => { + it('should render two handles with three elements', () => { renderStudioResizableLayoutContainer(); - expect(screen.getAllByRole('separator').length).toBe(1); + expect(screen.getAllByRole('separator').length).toBe(2); }); it('should resize containers', () => { renderStudioResizableLayoutContainer(); - const handle = screen.getByRole('separator'); + const handle = screen.getAllByRole('separator')[0]; dragHandle(handle, { clientX: 400 }, { clientX: 200 }); @@ -23,7 +23,7 @@ describe('StudioResizableLayoutContainer', () => { it('should not resize containers below minimum size', () => { // minimum flexgrow should be minimumSize/containerSize=0.25 renderStudioResizableLayoutContainer(); - const handle = screen.getByRole('separator'); + const handle = screen.getAllByRole('separator')[0]; dragHandle(handle, { clientX: 400 }, { clientX: 0 }); expect(screen.getAllByTestId('resizablelayoutelement')[0].style.flexGrow).toBe('0.25'); @@ -36,12 +36,29 @@ describe('StudioResizableLayoutContainer', () => { it('should not resize containers above maximum size', () => { renderStudioResizableLayoutContainer(600); - const handle = screen.getByRole('separator'); + const handle = screen.getAllByRole('separator')[0]; dragHandle(handle, { clientX: 400 }, { clientX: 800 }); expect(screen.getAllByTestId('resizablelayoutelement')[0].style.flexGrow).toBe('1.5'); expect(screen.getAllByTestId('resizablelayoutelement')[1].style.flexGrow).toBe('0.5'); }); + + it('should render StudioResizableLayoutHandle with base CSS classes', () => { + renderStudioResizableLayoutContainer(); + expect(screen.getAllByRole('separator')[0]).toHaveClass('resizeHandle'); + expect(screen.getAllByRole('separator')[1]).toHaveClass('resizeHandle'); + }); + + it('should render StudioResizableLayoutHandle with multiple CSS classes', () => { + renderStudioResizableLayoutContainer(); + expect(screen.getAllByRole('separator')[0]).toHaveClass('resizeHandle'); + expect(screen.getAllByRole('separator')[0]).toHaveClass('resizeHandleH'); + expect(screen.getAllByRole('separator')[0]).not.toHaveClass('hideLeftSide'); + + expect(screen.getAllByRole('separator')[1]).toHaveClass('resizeHandle'); + expect(screen.getAllByRole('separator')[1]).not.toHaveClass('resizeHandleH'); + expect(screen.getAllByRole('separator')[1]).not.toHaveClass('hideLeftSide'); + }); }); const dragHandle = ( @@ -73,6 +90,7 @@ const renderStudioResizableLayoutContainer = ( maximumSize={maximumSize} collapsed={collapsed} collapsedSize={400} + hasNeighbour={true} >
test1
@@ -81,8 +99,18 @@ const renderStudioResizableLayoutContainer = ( maximumSize={maximumSize} collapsed={collapsed} collapsedSize={400} + hasNeighbour={true} + disableRightHandle={true} > -
test1
+
test2
+ + +
test3
, ); diff --git a/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutElement/StudioResizableLayoutElement.tsx b/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutElement/StudioResizableLayoutElement.tsx index d131bc5912a..8568f53c910 100644 --- a/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutElement/StudioResizableLayoutElement.tsx +++ b/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutElement/StudioResizableLayoutElement.tsx @@ -12,6 +12,7 @@ export type StudioResizableLayoutElementProps = { style?: React.CSSProperties; onResizing?: (resizing: boolean) => void; + disableRightHandle?: boolean; //** supplied from container **// resize?: (size: number) => void; @@ -24,15 +25,16 @@ export type StudioResizableLayoutElementProps = { const StudioResizableLayoutElement = forwardRef( ( { - index, minimumSize = 0, maximumSize, collapsedSize, collapsed, - children, - hasNeighbour = false, style, + disableRightHandle, + index, onResizing, + hasNeighbour = false, + children, }: StudioResizableLayoutElementProps, ref, ): ReactElement => { @@ -58,6 +60,7 @@ const StudioResizableLayoutElement = forwardRef )} diff --git a/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutHandle/StudioResizableLayoutHandle.tsx b/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutHandle/StudioResizableLayoutHandle.tsx index eab6a97d745..8a16199db68 100644 --- a/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutHandle/StudioResizableLayoutHandle.tsx +++ b/frontend/libs/studio-components/src/components/StudioResizableLayout/StudioResizableLayoutHandle/StudioResizableLayoutHandle.tsx @@ -10,12 +10,14 @@ export type StudioResizableLayoutHandleProps = { orientation: StudioResizableOrientation; index: number; onResizing?: (resizing: boolean) => void; + disableRightHandle?: boolean; }; export const StudioResizableLayoutHandle = ({ orientation, index, onResizing, + disableRightHandle, }: StudioResizableLayoutHandleProps): ReactElement => { const { resizeDelta, containerSize } = useStudioResizableLayoutContext(index); const { onMouseDown, isResizing } = useStudioResizableLayoutMouseMovement( @@ -30,6 +32,17 @@ export const StudioResizableLayoutHandle = ({ onResizing?.(isResizing); }, [isResizing, onResizing]); + if (disableRightHandle) { + return ( +
+ ); + } + return (
{ collapsedSize={50} minimumSize={300} maximumSize={300} + disableRightHandle={true} >