Skip to content

Commit 942a71f

Browse files
authored
misc: fix studio panel resizing when dragging (#32584)
1 parent cef5820 commit 942a71f

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ _Released 10/07/2025 (PENDING)_
77

88
- Fixed a regression introduced in [`15.0.0`](https://docs.cypress.io/guides/references/changelog#15-0-0) where `dbus` connection error messages appear in docker containers when launching Cypress. Fixes [#32290](https://github.com/cypress-io/cypress/issues/32290).
99

10+
**Misc:**
11+
12+
- Fixed the Studio panel resizing when dragging. Addressed in [#32584](https://github.com/cypress-io/cypress/pull/32584).
13+
1014
## 15.3.0
1115

1216
_Released 9/23/2025_

packages/app/src/runner/ResizablePanels.cy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const slotContents = {
3030
panel4: () => <div class="h-full bg-yellow-100">panel4</div>,
3131
}
3232

33-
describe('<ResizablePanels />', { viewportWidth: 1500, defaultCommandTimeout: 4000 }, () => {
33+
describe('<ResizablePanels />', { viewportWidth: 1500 }, () => {
3434
describe('the panels resize as expected', () => {
3535
beforeEach(() => {
3636
cy.mount(() => (
@@ -110,7 +110,7 @@ describe('<ResizablePanels />', { viewportWidth: 1500, defaultCommandTimeout: 40
110110
})
111111
})
112112

113-
describe('when panel 4 is shown', () => {
113+
describe('when panel 4 is shown', { viewportWidth: 2000 }, () => {
114114
beforeEach(() => {
115115
cy.mount(() => (
116116
<div class="flex">
@@ -209,6 +209,7 @@ describe('<ResizablePanels />', { viewportWidth: 1500, defaultCommandTimeout: 40
209209
dragHandleToClientX('panel4', 1400)
210210
assertWidth('panel4', 600)
211211
dragHandleToClientX('panel4', 1660)
212+
assertWidth('panel4', minPanel4Width)
212213
dragHandleToClientX('panel4', 1800)
213214
assertWidth('panel4', minPanel4Width)
214215
dragHandleToClientX('panel4', 1900)

packages/app/src/runner/ResizablePanels.vue

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
<div
6767
data-cy="panel4ResizeHandle"
68-
class="cursor-ew-resize h-full top-0 left-[-6px] w-[10px] z-30 absolute"
68+
class="cursor-ew-resize h-full top-0 left-[-5px] w-[10px] z-30 absolute"
6969
@mousedown="handleMousedown('panel4', $event)"
7070
/>
7171
</div>
@@ -118,13 +118,14 @@ const emit = defineEmits<{
118118
119119
const panel1HandleX = ref(props.initialPanel1Width)
120120
const panel2HandleX = ref(props.initialPanel2Width + props.initialPanel1Width)
121-
const panel4HandleX = ref(props.initialPanel2Width + props.initialPanel1Width + props.initialPanel4Width)
122121
const panel1IsDragging = ref(false)
123122
const panel2IsDragging = ref(false)
124123
const panel4IsDragging = ref(false)
125124
const cachedPanel1Width = ref<number>(props.initialPanel1Width) // because panel 1 (the inline specs list) can be opened and closed in the UI, we cache the width
126125
const cachedPanel4Width = ref(props.initialPanel4Width)
127126
const panel2Width = ref(props.initialPanel2Width)
127+
const panel4InitialMouseX = ref(0) // Initial mouse position when panel4 drag starts
128+
const panel4InitialWidth = ref(0) // Initial panel width when panel4 drag starts
128129
129130
const handleMousedown = (panel: DraggablePanel, event: MouseEvent) => {
130131
if (panel === 'panel1') {
@@ -134,9 +135,11 @@ const handleMousedown = (panel: DraggablePanel, event: MouseEvent) => {
134135
panel2HandleX.value = event.clientX
135136
} else if (panel === 'panel4') {
136137
panel4IsDragging.value = true
137-
panel4HandleX.value = event.clientX
138+
panel4InitialMouseX.value = event.clientX
139+
panel4InitialWidth.value = cachedPanel4Width.value
138140
}
139141
}
142+
140143
const handleMousemove = (event: MouseEvent) => {
141144
if (!panel1IsDragging.value && !panel2IsDragging.value && !panel4IsDragging.value) {
142145
// nothing is dragging, ignore mousemove
@@ -153,13 +156,11 @@ const handleMousemove = (event: MouseEvent) => {
153156
panel2Width.value = event.clientX - props.offsetLeft - panel1Width.value
154157
emit('panelWidthUpdated', { panel: 'panel2', width: panel2Width.value })
155158
} else if (panel4IsDragging.value && isNewWidthAllowed(event.clientX, 'panel4')) {
156-
panel4HandleX.value = event.clientX
157-
// Calculate width from the right edge of the window
158-
// so that when we drag the panel to the left, it grows
159-
// and when we drag it to the right, it shrinks
160-
const rightEdge = props.maxTotalWidth + props.offsetLeft
159+
// panel4 resizes from the right edge, so we calculate based on mouse movement from the initial position
160+
const mouseDelta = event.clientX - panel4InitialMouseX.value
161+
const newWidth = panel4InitialWidth.value - mouseDelta
161162
162-
cachedPanel4Width.value = rightEdge - event.clientX
163+
cachedPanel4Width.value = newWidth
163164
emit('panelWidthUpdated', { panel: 'panel4', width: panel4Width.value })
164165
}
165166
}
@@ -258,8 +259,8 @@ function isNewWidthAllowed (mouseClientX: number, panel: DraggablePanel) {
258259
}
259260
260261
if (panel === 'panel4') {
261-
const rightEdge = props.maxTotalWidth + props.offsetLeft
262-
const newWidth = rightEdge - mouseClientX
262+
const mouseDelta = mouseClientX - panel4InitialMouseX.value
263+
const newWidth = panel4InitialWidth.value - mouseDelta
263264
264265
if (isMaxWidthSmall && newWidth >= props.minPanel4Width) {
265266
return true
@@ -270,6 +271,7 @@ function isNewWidthAllowed (mouseClientX: number, panel: DraggablePanel) {
270271
271272
return false
272273
}
274+
273275
watchEffect(() => {
274276
if (!props.showPanel1) {
275277
emit('panelWidthUpdated', { panel: 'panel1', width: 0 })

0 commit comments

Comments
 (0)