From f005afb71cc9734a72f13836310769a6a2c7b6b6 Mon Sep 17 00:00:00 2001 From: fullex <106392080+0xfullex@users.noreply.github.com> Date: Sat, 9 Aug 2025 10:22:31 +0800 Subject: [PATCH] fix(SelectionService): check screen edge to prevent toolbar overlay selection (#8972) feat(SelectionService): add toolbar boundary checks to prevent overflow on screen edges --- src/main/services/SelectionService.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/services/SelectionService.ts b/src/main/services/SelectionService.ts index bfee69da88..060708bb4b 100644 --- a/src/main/services/SelectionService.ts +++ b/src/main/services/SelectionService.ts @@ -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 }