I’m working on an extension for Chrome and have run into a problem with controlling the size of the popup window. I would like the user to not be able to shrink the window below a certain size. I’m using Chrome’s Manifest V3 and popup type.
I’ve tried applying CSS styles directly in the HTML file, but the window can still be resized to the minimum width.
Also tried using onBoundsChanged. It works, but it’s a bit weird. It allows you to shrink the window and then suddenly sets it to the desired width.
chrome.windows.onBoundsChanged.addListener(async (currentWindow) => {
const { height = 0, width = 0 } = currentWindow;
if (height < 800 || width < 400) {
await extension.windows.update(currentWindowId!, {
width: 400,
height: 800,
});
}
});
Also thought of doing it via setInterval
. But the result is the same, the window can be shrunk and then it suddenly becomes normal.
setInterval(async () => {
const currentWindow = await extension.windows.getCurrent();
const { height = 0, width = 0 } = currentWindow;
if (height < 800 || width < 400) {
await extension.windows.update(currentWindowId!, {
height: 800,
width: 400,
});
}
}, 500);
Maybe there are some other options to prevent the user from shrinking the window?