mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SDA-3516 (Refocus to main webContents when title bar action buttons are clicked) (#1326)
* SDA-3516 - Refocus to main webContents when title bar action button are clicked * SDA-3516 - Add getMainWebContents mock function
This commit is contained in:
parent
3d2bdbc23b
commit
5bcf36e7bd
@ -46,6 +46,7 @@ jest.mock('../src/app/window-handler', () => {
|
|||||||
isOnline: false,
|
isOnline: false,
|
||||||
updateVersionInfo: jest.fn(),
|
updateVersionInfo: jest.fn(),
|
||||||
isMana: false,
|
isMana: false,
|
||||||
|
getMainWebContents: jest.fn(),
|
||||||
appMenu: {
|
appMenu: {
|
||||||
buildMenu: jest.fn(),
|
buildMenu: jest.fn(),
|
||||||
},
|
},
|
||||||
|
@ -83,6 +83,7 @@ ipcMain.on(
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const mainWebContents = windowHandler.getMainWebContents();
|
||||||
logApiCallParams(arg);
|
logApiCallParams(arg);
|
||||||
switch (arg.cmd) {
|
switch (arg.cmd) {
|
||||||
case apiCmds.isOnline:
|
case apiCmds.isOnline:
|
||||||
@ -178,7 +179,6 @@ ipcMain.on(
|
|||||||
showPopupMenu({ window: browserWin });
|
showPopupMenu({ window: browserWin });
|
||||||
// Give focus back to main webContents so that
|
// Give focus back to main webContents so that
|
||||||
// cut, copy & paste from edit menu works as expected
|
// cut, copy & paste from edit menu works as expected
|
||||||
const mainWebContents = windowHandler.getMainWebContents();
|
|
||||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||||
mainWebContents.focus();
|
mainWebContents.focus();
|
||||||
}
|
}
|
||||||
@ -337,13 +337,25 @@ ipcMain.on(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case apiCmds.closeMainWindow:
|
case apiCmds.closeMainWindow:
|
||||||
|
// Give focus back to main webContents
|
||||||
|
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||||
|
mainWebContents.focus();
|
||||||
|
}
|
||||||
windowHandler.getMainWindow()?.close();
|
windowHandler.getMainWindow()?.close();
|
||||||
break;
|
break;
|
||||||
case apiCmds.minimizeMainWindow:
|
case apiCmds.minimizeMainWindow:
|
||||||
|
// Give focus back to main webContents
|
||||||
|
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||||
|
mainWebContents.focus();
|
||||||
|
}
|
||||||
windowHandler.getMainWindow()?.minimize();
|
windowHandler.getMainWindow()?.minimize();
|
||||||
break;
|
break;
|
||||||
case apiCmds.maximizeMainWindow:
|
case apiCmds.maximizeMainWindow:
|
||||||
windowHandler.getMainWindow()?.maximize();
|
windowHandler.getMainWindow()?.maximize();
|
||||||
|
// Give focus back to main webContents
|
||||||
|
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||||
|
mainWebContents.focus();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case apiCmds.unmaximizeMainWindow:
|
case apiCmds.unmaximizeMainWindow:
|
||||||
const mainWindow = windowHandler.getMainWindow();
|
const mainWindow = windowHandler.getMainWindow();
|
||||||
@ -352,6 +364,10 @@ ipcMain.on(
|
|||||||
? mainWindow.setFullScreen(false)
|
? mainWindow.setFullScreen(false)
|
||||||
: mainWindow.unmaximize();
|
: mainWindow.unmaximize();
|
||||||
}
|
}
|
||||||
|
// Give focus back to main webContents
|
||||||
|
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||||
|
mainWebContents.focus();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case apiCmds.setPodUrl:
|
case apiCmds.setPodUrl:
|
||||||
await config.updateUserConfig({ url: arg.newPodUrl });
|
await config.updateUserConfig({ url: arg.newPodUrl });
|
||||||
|
@ -260,6 +260,15 @@ export class WindowHandler {
|
|||||||
app.getLocale()) as LocaleType;
|
app.getLocale()) as LocaleType;
|
||||||
i18n.setLocale(locale);
|
i18n.setLocale(locale);
|
||||||
|
|
||||||
|
logger.info(`window handler: env details`, {
|
||||||
|
contextIsolation: this.contextIsolation,
|
||||||
|
isNodeEnv,
|
||||||
|
isDevEnv,
|
||||||
|
isMac,
|
||||||
|
isWindowsOS,
|
||||||
|
isLinux,
|
||||||
|
});
|
||||||
|
|
||||||
this.listenForLoad();
|
this.listenForLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user