Skip to content

Commit 85e6056

Browse files
committed
environment/permissions: Fix permission popup not showing
`window.screen` is not available in manifest v3, causing the prompt window fallback method to fail.
1 parent 2837707 commit 85e6056

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/environment/background/permissions.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ async function makePromptWindow({ permissions, origins }) {
2424

2525
const width = 630;
2626
const height = 255;
27-
// Display popup on middle of screen
28-
const left = Math.floor(screen.width / 2 - width / 2);
29-
const top = Math.floor(screen.height / 2 - height / 2);
27+
28+
// Get the current window's dimensions and calculate center position
29+
const { width: screenWidth, height: screenHeight } = await chrome.windows.getCurrent();
30+
const left = Math.floor(screenWidth / 2 - width / 2);
31+
const top = Math.floor(screenHeight / 2 - height / 2);
3032

3133
const { tabs: [{ id }] } = await apiToPromise(chrome.windows.create)({ url: url.href, type: 'popup', width, height, left, top });
3234

0 commit comments

Comments
 (0)