Skip to content

Commit fc8dcb2

Browse files
Update package version and improve layout responsiveness in RootLandscape and SideDrawer components. Enhance Apps and Notes drawer visibility during resizing in Apps.spec.ts tests.
1 parent 1e7922e commit fc8dcb2

File tree

6 files changed

+85
-10
lines changed

6 files changed

+85
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bldrs",
3-
"version": "1.0.1890",
3+
"version": "1.0.1892",
44
"main": "src/index.jsx",
55
"license": "AGPL-3.0",
66
"homepage": "https://github.com/bldrs-ai/Share",

src/Components/Apps/Apps.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
homepageSetup,
44
returningUserVisitsHomepageWaitForModel,
55
} from '../../tests/e2e/utils'
6+
import {TITLE_NOTES} from '../Notes/component'
67
import {TITLE_APPS} from './component'
78

89

@@ -47,5 +48,41 @@ describe('AppsSideDrawer', () => {
4748
expect(parseInt(width)).toBeGreaterThan(MIN_FULLSCREEN_WIDTH)
4849
})
4950
})
51+
52+
test('resizing Notes drawer does not push Apps off-screen', async ({page}) => {
53+
// Open both Notes and Apps.
54+
await page.getByTestId('control-button-notes').click()
55+
await page.getByTestId('control-button-apps').click()
56+
57+
// Sanity: both titles visible.
58+
await expect(page.getByTestId(`PanelTitle-${TITLE_NOTES}`)).toBeVisible()
59+
await expect(page.getByTestId(`PanelTitle-${TITLE_APPS}`)).toBeVisible()
60+
61+
const notesDrawer = page.getByTestId('NotesAndPropertiesDrawer')
62+
const appsDrawer = page.getByTestId('AppsDrawer')
63+
64+
const handle = notesDrawer.getByTestId('resize-handle-x')
65+
const handleBox = await handle.boundingBox()
66+
expect(handleBox).toBeTruthy()
67+
68+
// Drag left to widen Notes (this used to push Apps out of view).
69+
await page.mouse.move(
70+
handleBox!.x + handleBox!.width / 2,
71+
handleBox!.y + handleBox!.height / 2,
72+
)
73+
await page.mouse.down()
74+
await page.mouse.move(handleBox!.x - 250, handleBox!.y + handleBox!.height / 2)
75+
await page.mouse.up()
76+
77+
// Apps should remain visible and inside the viewport.
78+
await expect(page.getByTestId(`PanelTitle-${TITLE_APPS}`)).toBeVisible()
79+
80+
const appsBox = await appsDrawer.boundingBox()
81+
expect(appsBox).toBeTruthy()
82+
83+
const vw = await page.evaluate(() => window.innerWidth)
84+
expect(appsBox!.x).toBeGreaterThanOrEqual(0)
85+
expect(appsBox!.x + appsBox!.width).toBeLessThanOrEqual(vw + 1)
86+
})
5087
})
5188
})

src/Components/SideDrawer/SideDrawer.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export default function SideDrawer({
4444
sx={Object.assign({
4545
display: isDrawerVisible ? 'flex' : 'none',
4646
flexDirection: 'row',
47-
flexGrow: 1,
47+
// Desktop drawers must be fixed-width flex items.
48+
// If they grow/shrink, resizing one drawer can push siblings off-screen.
49+
...(isMobile ? {} : {flex: '0 0 auto', flexShrink: 0}),
4850
}, isMobile ? {
4951
width: '100%',
5052
height: drawerHeight,

src/Containers/CadView.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export default function CadView({
5252
const elementTypesMap = useStore((state) => state.elementTypesMap)
5353
const isAppsVisible = useStore((state) => state.isAppsVisible)
5454
const isNotesVisible = useStore((state) => state.isNotesVisible)
55+
const rightDrawerWidth = useStore((state) => state.rightDrawerWidth)
56+
const appsDrawerWidth = useStore((state) => state.appsDrawerWidth)
5557
const preselectedElementIds = useStore((state) => state.preselectedElementIds)
5658
const searchIndex = useStore((state) => state.searchIndex)
5759
const selectedElements = useStore((state) => state.selectedElements)
@@ -68,7 +70,7 @@ export default function CadView({
6870
const setSelectedElement = useStore((state) => state.setSelectedElement)
6971
const setSelectedElements = useStore((state) => state.setSelectedElements)
7072
const setViewer = useStore((state) => state.setViewer)
71-
const sidebarWidth = useStore((state) => state.sidebarWidth)
73+
const sidebarWidth = (isNotesVisible ? rightDrawerWidth : 0) + (isAppsVisible ? appsDrawerWidth : 0)
7274
const viewer = useStore((state) => state.viewer)
7375

7476
// AppSlice

src/Containers/RootLandscape.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ export default function RootLandscape({pathPrefix, branch, selectWithShiftClickE
2828
return (
2929
<Stack
3030
direction='row'
31-
justifyContent='space-between'
32-
alignItems='center'
33-
sx={{width: '100%', height: isMobile ? `${vh}px` : '100vh'}}
31+
justifyContent='flex-start'
32+
alignItems='stretch'
33+
sx={{width: '100%', height: isMobile ? `${vh}px` : '100vh', overflow: 'hidden'}}
3434
data-testid='RootLandscape-RootStack'
3535
>
3636
{!isMobile &&
3737
<Box
3838
sx={{
39-
flexBasis: '0%',
40-
flexGrow: 1,
39+
// Left drawer should take only its own width.
40+
flex: '0 0 auto',
41+
flexShrink: 0,
4142
}}
4243
>
4344
<NavTreeAndVersionsDrawer
@@ -49,7 +50,7 @@ export default function RootLandscape({pathPrefix, branch, selectWithShiftClickE
4950
}
5051
<Stack
5152
justifyContent='space-between'
52-
sx={{width: '100%', height: '100%'}}
53+
sx={{flex: '1 1 auto', minWidth: 0, height: '100%'}}
5354
data-testid='CenterPane'
5455
>
5556
<Box sx={{opacity: 0.5}}>
@@ -71,7 +72,7 @@ export default function RootLandscape({pathPrefix, branch, selectWithShiftClickE
7172
justifyContent='space-between'
7273
// This pushes bottom bar down
7374
flexGrow={1}
74-
sx={{width: '100%'}}
75+
sx={{width: '100%', minWidth: 0}}
7576
data-testid='RootLandscape-CenterPaneTopStack'
7677
>
7778
<ControlsGroup/>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react'
2+
import {render} from '@testing-library/react'
3+
import ShareMock from '../ShareMock'
4+
import RootLandscape from './RootLandscape'
5+
6+
7+
jest.mock('./ControlsGroup', () => () => <div data-testid='MockControlsGroup'/>)
8+
jest.mock('./OperationsGroup', () => () => <div data-testid='MockOperationsGroup'/>)
9+
10+
11+
describe('RootLandscape', () => {
12+
it('center pane is flex and root does not overflow', () => {
13+
const {getByTestId} = render(
14+
<ShareMock>
15+
<RootLandscape
16+
pathPrefix=''
17+
branch=''
18+
selectWithShiftClickEvents={jest.fn()}
19+
deselectItems={jest.fn()}
20+
/>
21+
</ShareMock>,
22+
)
23+
24+
const root = getByTestId('RootLandscape-RootStack')
25+
const centerPane = getByTestId('CenterPane')
26+
27+
expect(getComputedStyle(root).overflow).toBe('hidden')
28+
29+
// Center pane should shrink when drawers grow.
30+
expect(getComputedStyle(centerPane).flexGrow).toBe('1')
31+
expect(getComputedStyle(centerPane).minWidth).toMatch(/^0(px)?$/)
32+
})
33+
})

0 commit comments

Comments
 (0)