Navigation Menu

Skip to content

Commit

Permalink
fix: After zoom/reset navigating displays "white screen" (#1947)
Browse files Browse the repository at this point in the history
Co-authored-by: André Pesci Cazetto <cazetto.andre@gmail.com>
Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com>
  • Loading branch information
3 people committed Sep 14, 2021
1 parent bc7c0e5 commit a1323df
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/ui/main/menuBar.ts
Expand Up @@ -352,7 +352,12 @@ const createViewMenu = createSelector(
browserWindow.showInactive();
}
browserWindow.focus();
browserWindow.webContents.zoomLevel = 0;
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return;
}
const guestWebContents = getWebContentsByServerUrl(url);
guestWebContents?.setZoomLevel(0);
},
},
{
Expand All @@ -361,15 +366,24 @@ const createViewMenu = createSelector(
accelerator: 'CommandOrControl+Plus',
click: async () => {
const browserWindow = await getRootWindow();

if (!browserWindow.isVisible()) {
browserWindow.showInactive();
}
browserWindow.focus();
if (browserWindow.webContents.zoomLevel >= 9) {
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return;
}
const guestWebContents = getWebContentsByServerUrl(url);
if (!guestWebContents) {
return;
}
const zoomLevel = guestWebContents?.getZoomLevel();
if (zoomLevel >= 9) {
return;
}
browserWindow.webContents.zoomLevel++;

guestWebContents.setZoomLevel(zoomLevel + 1);
},
},
{
Expand All @@ -378,15 +392,26 @@ const createViewMenu = createSelector(
accelerator: 'CommandOrControl+-',
click: async () => {
const browserWindow = await getRootWindow();

if (!browserWindow.isVisible()) {
browserWindow.showInactive();
}
browserWindow.focus();
if (browserWindow.webContents.zoomLevel <= -9) {
const url = typeof currentView === 'object' ? currentView.url : null;
if (!url) {
return;
}

const guestWebContents = getWebContentsByServerUrl(url);
if (!guestWebContents) {
return;
}
browserWindow.webContents.zoomLevel--;

const zoomLevel = guestWebContents.getZoomLevel();
if (zoomLevel <= -9) {
return;
}

guestWebContents.setZoomLevel(zoomLevel - 1);
},
},
],
Expand Down

0 comments on commit a1323df

Please sign in to comment.