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 }