Skip to content

Commit

Permalink
fix: win.closeFilePreview recreates panel when called twice (electron…
Browse files Browse the repository at this point in the history
…#45319)

* fix: close quick look during tests on macOS

* use longer delay 🤷

* fix: sharedPreviewPanel being recreated on close

* test: ensure preview panel gets closed
  • Loading branch information
samuelmaddock authored Feb 17, 2025
1 parent c0422d7 commit 6be1151
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,11 @@ static bool FromV8(v8::Isolate* isolate,
}

void NativeWindowMac::CloseFilePreview() {
if ([QLPreviewPanel sharedPreviewPanelExists]) {
// Need to be careful about checking [QLPreviewPanel sharedPreviewPanel] as
// simply accessing it will cause it to reinitialize and reappear.
if ([QLPreviewPanel sharedPreviewPanelExists] && preview_item_) {
[[QLPreviewPanel sharedPreviewPanel] close];
preview_item_ = nil;
}
}

Expand Down
1 change: 1 addition & 0 deletions spec/api-browser-window-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6256,6 +6256,7 @@ describe('BrowserWindow module', () => {
w.previewFile(__filename);
await setTimeout(500);
expect(showCalled).to.equal(false, 'should not have called show twice');
w.closeFilePreview();
});
});

Expand Down

0 comments on commit 6be1151

Please sign in to comment.