mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: win.closeFilePreview recreates panel when called twice (#45663)
* 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:
@@ -1556,8 +1556,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6223,6 +6223,7 @@ describe('BrowserWindow module', () => {
|
||||
w.previewFile(__filename);
|
||||
await setTimeout(500);
|
||||
expect(showCalled).to.equal(false, 'should not have called show twice');
|
||||
w.closeFilePreview();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user