[MM-44022] Switch to using current BrowserView for determining window bounds for URL view (#2087) (#2091)

(cherry picked from commit ebf5897f99)

Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
This commit is contained in:
Mattermost Build 2022-05-09 16:27:09 +02:00 committed by GitHub
parent fd0e1b55e2
commit adde4b2b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ import {BrowserViewConstructorOptions} from 'electron/main';
import {Tab, TeamWithTabs} from 'types/config';
import {SECOND} from 'common/utils/constants';
import {SECOND, TAB_BAR_HEIGHT} from 'common/utils/constants';
import {
UPDATE_TARGET_URL,
LOAD_SUCCESS,
@ -322,7 +322,7 @@ export class ViewManager {
const localURL = getLocalURLString('urlView.html', query);
urlView.webContents.loadURL(localURL);
this.mainWindow.addBrowserView(urlView);
const boundaries = this.mainWindow.getBounds();
const boundaries = this.views.get(this.currentView || '')?.view.getBounds() ?? this.mainWindow.getBounds();
const hideView = () => {
delete this.urlViewCancel;
@ -338,12 +338,15 @@ export class ViewManager {
const adjustWidth = (event: IpcMainEvent, width: number) => {
log.silly('showURLView.adjustWidth', width);
urlView.setBounds({
const bounds = {
x: 0,
y: boundaries.height - URL_VIEW_HEIGHT,
y: (boundaries.height + TAB_BAR_HEIGHT) - URL_VIEW_HEIGHT,
width: width + 5, // add some padding to ensure that we don't cut off the border
height: URL_VIEW_HEIGHT,
});
};
log.silly('showURLView setBounds', boundaries, bounds);
urlView.setBounds(bounds);
};
ipcMain.on(UPDATE_URL_VIEW_WIDTH, adjustWidth);