Skip to content

Commit e21259b

Browse files
tzaholaMrHuangJser
authored andcommitted
fix: add missing set_wants_to_be_visible(true) to NativeWindowMac::ShowInactive() (electron#40546)
* fix: add missing set_wants_to_be_visible(true) to NativeWindowMac::ShowInactive() * add test
1 parent d4b3333 commit e21259b

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

shell/browser/native_window_mac.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ void ReorderChildWindowAbove(NSWindow* child_window, NSWindow* other_window) {
534534
}
535535

536536
void NativeWindowMac::ShowInactive() {
537+
set_wants_to_be_visible(true);
538+
537539
// Reattach the window to the parent to actually show it.
538540
if (parent())
539541
InternalSetParentWindow(parent(), true);

spec/api-browser-window-spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,34 @@ describe('BrowserWindow module', () => {
11441144
await shown;
11451145
expect(w.isMaximized()).to.equal(true);
11461146
});
1147+
1148+
ifit(process.platform === 'darwin')('should attach child window to parent', async () => {
1149+
const wShow = once(w, 'show');
1150+
w.show();
1151+
await wShow;
1152+
1153+
const c = new BrowserWindow({ show: false, parent: w });
1154+
const cShow = once(c, 'show');
1155+
c.showInactive();
1156+
await cShow;
1157+
1158+
// verifying by checking that the child tracks the parent's visibility
1159+
const minimized = once(w, 'minimize');
1160+
w.minimize();
1161+
await minimized;
1162+
1163+
expect(w.isVisible()).to.be.false('parent is visible');
1164+
expect(c.isVisible()).to.be.false('child is visible');
1165+
1166+
const restored = once(w, 'restore');
1167+
w.restore();
1168+
await restored;
1169+
1170+
expect(w.isVisible()).to.be.true('parent is visible');
1171+
expect(c.isVisible()).to.be.true('child is visible');
1172+
1173+
closeWindow(c);
1174+
});
11471175
});
11481176

11491177
describe('BrowserWindow.focus()', () => {

0 commit comments

Comments
 (0)