Skip to content

Commit

Permalink
environment/permissions: Fix permission popup not showing (#5538)
Browse files Browse the repository at this point in the history
* environment/permissions: Fix permission popup not showing

`window.screen` is not available in manifest v3, causing the prompt window fallback method to fail.

* Add default values if no windows are returned
  • Loading branch information
larsjohnsen authored Sep 21, 2024
1 parent a735b44 commit 3b15c36
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/environment/background/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() || { width: 1920, height: 1080 };
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 });

Expand Down

0 comments on commit 3b15c36

Please sign in to comment.