mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-04 20:00:00 +08:00
fix(SelectionService): check screen edge to prevent toolbar overlay selection (#8972)
feat(SelectionService): add toolbar boundary checks to prevent overflow on screen edges
This commit is contained in:
parent
33128195fe
commit
f005afb71c
@ -707,6 +707,10 @@ export class SelectionService {
|
|||||||
//use original point to get the display
|
//use original point to get the display
|
||||||
const display = screen.getDisplayNearestPoint(refPoint)
|
const display = screen.getDisplayNearestPoint(refPoint)
|
||||||
|
|
||||||
|
//check if the toolbar exceeds the top or bottom of the screen
|
||||||
|
const exceedsTop = posPoint.y < display.workArea.y
|
||||||
|
const exceedsBottom = posPoint.y > display.workArea.y + display.workArea.height - toolbarHeight
|
||||||
|
|
||||||
// Ensure toolbar stays within screen boundaries
|
// Ensure toolbar stays within screen boundaries
|
||||||
posPoint.x = Math.round(
|
posPoint.x = Math.round(
|
||||||
Math.max(display.workArea.x, Math.min(posPoint.x, display.workArea.x + display.workArea.width - toolbarWidth))
|
Math.max(display.workArea.x, Math.min(posPoint.x, display.workArea.x + display.workArea.width - toolbarWidth))
|
||||||
@ -715,6 +719,14 @@ export class SelectionService {
|
|||||||
Math.max(display.workArea.y, Math.min(posPoint.y, display.workArea.y + display.workArea.height - toolbarHeight))
|
Math.max(display.workArea.y, Math.min(posPoint.y, display.workArea.y + display.workArea.height - toolbarHeight))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//adjust the toolbar position if it exceeds the top or bottom of the screen
|
||||||
|
if (exceedsTop) {
|
||||||
|
posPoint.y = posPoint.y + 32
|
||||||
|
}
|
||||||
|
if (exceedsBottom) {
|
||||||
|
posPoint.y = posPoint.y - 32
|
||||||
|
}
|
||||||
|
|
||||||
return posPoint
|
return posPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user