diff --git a/lib/environment/background/permissions.js b/lib/environment/background/permissions.js index d8a6948d75..0810d2cee9 100644 --- a/lib/environment/background/permissions.js +++ b/lib/environment/background/permissions.js @@ -24,9 +24,11 @@ async function makePromptWindow({ permissions, origins }) { const width = 630; const height = 255; - // Display popup on middle of screen - const left = Math.floor(screen.width / 2 - width / 2); - const top = Math.floor(screen.height / 2 - height / 2); + + // Get the current window's dimensions and calculate center position + const { width: screenWidth, height: screenHeight } = await chrome.windows.getCurrent(); + const left = Math.floor(screenWidth / 2 - width / 2); + const top = Math.floor(screenHeight / 2 - height / 2); const { tabs: [{ id }] } = await apiToPromise(chrome.windows.create)({ url: url.href, type: 'popup', width, height, left, top });