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:
fullex 2025-08-09 10:22:31 +08:00 committed by GitHub
parent 33128195fe
commit f005afb71c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -707,6 +707,10 @@ export class SelectionService {
//use original point to get the display
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
posPoint.x = Math.round(
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))
)
//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
}