[MM-38459] Resize the menu instead of removing the browser view altogether (#1730)
This commit is contained in:
@@ -32,12 +32,14 @@ export default class TeamDropdownView {
|
|||||||
expired?: Map<string, boolean>;
|
expired?: Map<string, boolean>;
|
||||||
window: BrowserWindow;
|
window: BrowserWindow;
|
||||||
windowBounds: Electron.Rectangle;
|
windowBounds: Electron.Rectangle;
|
||||||
|
isOpen: boolean;
|
||||||
|
|
||||||
constructor(window: BrowserWindow, teams: TeamWithTabs[], darkMode: boolean, enableServerManagement: boolean) {
|
constructor(window: BrowserWindow, teams: TeamWithTabs[], darkMode: boolean, enableServerManagement: boolean) {
|
||||||
this.teams = teams;
|
this.teams = teams;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
this.darkMode = darkMode;
|
this.darkMode = darkMode;
|
||||||
this.enableServerManagement = enableServerManagement;
|
this.enableServerManagement = enableServerManagement;
|
||||||
|
this.isOpen = false;
|
||||||
|
|
||||||
this.windowBounds = this.window.getContentBounds();
|
this.windowBounds = this.window.getContentBounds();
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ export default class TeamDropdownView {
|
|||||||
}});
|
}});
|
||||||
|
|
||||||
this.view.webContents.loadURL(getLocalURLString('dropdown.html'));
|
this.view.webContents.loadURL(getLocalURLString('dropdown.html'));
|
||||||
|
this.window.addBrowserView(this.view);
|
||||||
|
|
||||||
ipcMain.on(OPEN_TEAMS_DROPDOWN, this.handleOpen);
|
ipcMain.on(OPEN_TEAMS_DROPDOWN, this.handleOpen);
|
||||||
ipcMain.on(CLOSE_TEAMS_DROPDOWN, this.handleClose);
|
ipcMain.on(CLOSE_TEAMS_DROPDOWN, this.handleClose);
|
||||||
@@ -101,22 +104,27 @@ export default class TeamDropdownView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOpen = () => {
|
handleOpen = () => {
|
||||||
this.window.addBrowserView(this.view);
|
if (!this.bounds) {
|
||||||
const bounds = this.view.getBounds();
|
return;
|
||||||
this.view.setBounds(this.getBounds(bounds.width, bounds.height));
|
}
|
||||||
|
this.view.setBounds(this.bounds);
|
||||||
this.window.setTopBrowserView(this.view);
|
this.window.setTopBrowserView(this.view);
|
||||||
this.view.webContents.focus();
|
this.view.webContents.focus();
|
||||||
WindowManager.sendToRenderer(OPEN_TEAMS_DROPDOWN);
|
WindowManager.sendToRenderer(OPEN_TEAMS_DROPDOWN);
|
||||||
|
this.isOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClose = () => {
|
handleClose = () => {
|
||||||
this.window.removeBrowserView(this.view);
|
this.view.setBounds(this.getBounds(0, 0));
|
||||||
WindowManager.sendToRenderer(CLOSE_TEAMS_DROPDOWN);
|
WindowManager.sendToRenderer(CLOSE_TEAMS_DROPDOWN);
|
||||||
|
this.isOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleReceivedMenuSize = (event: IpcMainEvent, width: number, height: number) => {
|
handleReceivedMenuSize = (event: IpcMainEvent, width: number, height: number) => {
|
||||||
const bounds = this.getBounds(width, height);
|
this.bounds = this.getBounds(width, height);
|
||||||
this.view.setBounds(bounds);
|
if (this.isOpen) {
|
||||||
|
this.view.setBounds(this.bounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getBounds = (width: number, height: number) => {
|
getBounds = (width: number, height: number) => {
|
||||||
|
Reference in New Issue
Block a user