Skip to content

Commit a131f36

Browse files
authored
[Fix] Fix out of bound issue when window was close and reopen at diff size (#3906)
1 parent 4cad1a9 commit a131f36

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/components/actionbar/ComfyActionbar.vue

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ watchDebounced(
6363
6464
// Set initial position to bottom center
6565
const setInitialPosition = () => {
66-
if (x.value !== 0 || y.value !== 0) {
67-
return
68-
}
69-
if (storedPosition.value.x !== 0 || storedPosition.value.y !== 0) {
70-
x.value = storedPosition.value.x
71-
y.value = storedPosition.value.y
72-
captureLastDragState()
73-
return
74-
}
7566
if (panelRef.value) {
7667
const screenWidth = window.innerWidth
7768
const screenHeight = window.innerHeight
@@ -82,9 +73,25 @@ const setInitialPosition = () => {
8273
return
8374
}
8475
85-
x.value = (screenWidth - menuWidth) / 2
86-
y.value = screenHeight - menuHeight - 10 // 10px margin from bottom
87-
captureLastDragState()
76+
// Check if stored position exists and is within bounds
77+
if (storedPosition.value.x !== 0 || storedPosition.value.y !== 0) {
78+
// Ensure stored position is within screen bounds
79+
x.value = clamp(storedPosition.value.x, 0, screenWidth - menuWidth)
80+
y.value = clamp(storedPosition.value.y, 0, screenHeight - menuHeight)
81+
captureLastDragState()
82+
return
83+
}
84+
85+
// If no stored position or current position, set to bottom center
86+
if (x.value === 0 && y.value === 0) {
87+
x.value = clamp((screenWidth - menuWidth) / 2, 0, screenWidth - menuWidth)
88+
y.value = clamp(
89+
screenHeight - menuHeight - 10,
90+
0,
91+
screenHeight - menuHeight
92+
)
93+
captureLastDragState()
94+
}
8895
}
8996
}
9097
onMounted(setInitialPosition)

0 commit comments

Comments
 (0)