fix: setTopBrowserView focus issue with reordering (#42734)

This commit is contained in:
trop[bot] 2024-07-02 14:09:28 +02:00 committed by GitHub
parent 3ab4b22460
commit 9d3195bec1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -209,7 +209,12 @@ BrowserWindow.prototype.getBrowserViews = function () {
BrowserWindow.prototype.setTopBrowserView = function (browserView: BrowserView) {
if (browserView.ownerWindow !== this) { throw new Error('Given BrowserView is not attached to the window'); }
this.addBrowserView(browserView);
const idx = this._browserViews.indexOf(browserView);
if (idx >= 0) {
this.contentView.addChildView(browserView.webContentsView);
this._browserViews.splice(idx, 1);
this._browserViews.push(browserView);
}
};
module.exports = BrowserWindow;