Skip to content

Commit 5b68f3e

Browse files
committed
End/close AppKit sheets attached on window when we hide it (#17968)
1 parent 7895ad4 commit 5b68f3e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: native/Avalonia.Native/src/OSX/WindowBaseImpl.mm

+13
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@
143143

144144
@autoreleasepool {
145145
if (Window != nullptr) {
146+
147+
// If window is hidden without ending attached sheet first, it will stuck in "order out" state,
148+
// and block any new sheets from being attached.
149+
// Additionaly, we don't know if user would define any custom panels, so we only end/close file dialog sheets.
150+
auto attachedSheet = Window.attachedSheet;
151+
if (attachedSheet
152+
&& ([attachedSheet isKindOfClass: [NSOpenPanel class]]
153+
|| [attachedSheet isKindOfClass: [NSSavePanel class]]))
154+
{
155+
[Window endSheet:attachedSheet];
156+
[attachedSheet close];
157+
}
158+
146159
auto frame = [Window frame];
147160

148161
AvnPoint point;

0 commit comments

Comments
 (0)