fix: pre-size menu context card
parent
8c18dd40a3
commit
ce4b68d5fb
|
|
@ -48,6 +48,7 @@ final class MenuContextCardInjector: NSObject, NSMenuDelegate {
|
||||||
let initialRows = self.cachedRows
|
let initialRows = self.cachedRows
|
||||||
let initialIsLoading = initialRows.isEmpty
|
let initialIsLoading = initialRows.isEmpty
|
||||||
let initialStatusText = initialIsLoading ? self.cacheErrorText : nil
|
let initialStatusText = initialIsLoading ? self.cacheErrorText : nil
|
||||||
|
let initialWidth = self.initialCardWidth(for: menu)
|
||||||
|
|
||||||
let initial = AnyView(ContextMenuCardView(
|
let initial = AnyView(ContextMenuCardView(
|
||||||
rows: initialRows,
|
rows: initialRows,
|
||||||
|
|
@ -55,8 +56,8 @@ final class MenuContextCardInjector: NSObject, NSMenuDelegate {
|
||||||
isLoading: initialIsLoading))
|
isLoading: initialIsLoading))
|
||||||
|
|
||||||
let hosting = NSHostingView(rootView: initial)
|
let hosting = NSHostingView(rootView: initial)
|
||||||
|
hosting.frame.size.width = max(1, initialWidth)
|
||||||
let size = hosting.fittingSize
|
let size = hosting.fittingSize
|
||||||
let initialWidth = self.initialCardWidth(for: menu)
|
|
||||||
hosting.frame = NSRect(
|
hosting.frame = NSRect(
|
||||||
origin: .zero,
|
origin: .zero,
|
||||||
size: NSSize(width: initialWidth, height: size.height))
|
size: NSSize(width: initialWidth, height: size.height))
|
||||||
|
|
@ -83,6 +84,7 @@ final class MenuContextCardInjector: NSObject, NSMenuDelegate {
|
||||||
hosting.rootView = view
|
hosting.rootView = view
|
||||||
hosting.invalidateIntrinsicContentSize()
|
hosting.invalidateIntrinsicContentSize()
|
||||||
self.captureMenuWidthIfAvailable(for: menu, hosting: hosting)
|
self.captureMenuWidthIfAvailable(for: menu, hosting: hosting)
|
||||||
|
hosting.frame.size.width = max(1, initialWidth)
|
||||||
let size = hosting.fittingSize
|
let size = hosting.fittingSize
|
||||||
hosting.frame.size.height = size.height
|
hosting.frame.size.height = size.height
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue