Skip to content

Commit a1323df

Browse files
vuongtaquocAndré Pesci Cazettoggazzo
authored
fix: After zoom/reset navigating displays "white screen" (#1947)
Co-authored-by: André Pesci Cazetto <cazetto.andre@gmail.com> Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com>
1 parent bc7c0e5 commit a1323df

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

src/ui/main/menuBar.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@ const createViewMenu = createSelector(
352352
browserWindow.showInactive();
353353
}
354354
browserWindow.focus();
355-
browserWindow.webContents.zoomLevel = 0;
355+
const url = typeof currentView === 'object' ? currentView.url : null;
356+
if (!url) {
357+
return;
358+
}
359+
const guestWebContents = getWebContentsByServerUrl(url);
360+
guestWebContents?.setZoomLevel(0);
356361
},
357362
},
358363
{
@@ -361,15 +366,24 @@ const createViewMenu = createSelector(
361366
accelerator: 'CommandOrControl+Plus',
362367
click: async () => {
363368
const browserWindow = await getRootWindow();
364-
365369
if (!browserWindow.isVisible()) {
366370
browserWindow.showInactive();
367371
}
368372
browserWindow.focus();
369-
if (browserWindow.webContents.zoomLevel >= 9) {
373+
const url = typeof currentView === 'object' ? currentView.url : null;
374+
if (!url) {
375+
return;
376+
}
377+
const guestWebContents = getWebContentsByServerUrl(url);
378+
if (!guestWebContents) {
379+
return;
380+
}
381+
const zoomLevel = guestWebContents?.getZoomLevel();
382+
if (zoomLevel >= 9) {
370383
return;
371384
}
372-
browserWindow.webContents.zoomLevel++;
385+
386+
guestWebContents.setZoomLevel(zoomLevel + 1);
373387
},
374388
},
375389
{
@@ -378,15 +392,26 @@ const createViewMenu = createSelector(
378392
accelerator: 'CommandOrControl+-',
379393
click: async () => {
380394
const browserWindow = await getRootWindow();
381-
382395
if (!browserWindow.isVisible()) {
383396
browserWindow.showInactive();
384397
}
385398
browserWindow.focus();
386-
if (browserWindow.webContents.zoomLevel <= -9) {
399+
const url = typeof currentView === 'object' ? currentView.url : null;
400+
if (!url) {
401+
return;
402+
}
403+
404+
const guestWebContents = getWebContentsByServerUrl(url);
405+
if (!guestWebContents) {
387406
return;
388407
}
389-
browserWindow.webContents.zoomLevel--;
408+
409+
const zoomLevel = guestWebContents.getZoomLevel();
410+
if (zoomLevel <= -9) {
411+
return;
412+
}
413+
414+
guestWebContents.setZoomLevel(zoomLevel - 1);
390415
},
391416
},
392417
],

0 commit comments

Comments
 (0)