fix: win.closeFilePreview recreates panel when called twice (#45661)

* fix: close quick look during tests on macOS

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* use longer delay 🤷

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: sharedPreviewPanel being recreated on close

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* test: ensure preview panel gets closed

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
trop[bot] 2025-02-18 09:56:17 +01:00 committed by GitHub
parent 9d44b31be5
commit e50e2d041e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -1557,8 +1557,11 @@ void NativeWindowMac::PreviewFile(const std::string& path,
}
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;
}
}

View file

@ -6218,6 +6218,7 @@ describe('BrowserWindow module', () => {
w.previewFile(__filename);
await setTimeout(500);
expect(showCalled).to.equal(false, 'should not have called show twice');
w.closeFilePreview();
});
});