Fix pill visibility: always render, use opacity to hide
NSHostingView with frame (0,0) won't layout SwiftUI content, so fittingSize always returns 0 when transitioning from EmptyView. Instead, always render the pill button and use opacity/frame(0) to hide when idle. This ensures the hosting view always has content to measure.
This commit is contained in:
parent
498cc6e4bc
commit
59370115ce
1 changed files with 12 additions and 11 deletions
|
|
@ -11,17 +11,18 @@ struct UpdatePill: View {
|
|||
|
||||
var body: some View {
|
||||
let state = model.effectiveState
|
||||
if !state.isIdle {
|
||||
pillButton
|
||||
.popover(
|
||||
isPresented: $showPopover,
|
||||
attachmentAnchor: .rect(.bounds),
|
||||
arrowEdge: .top
|
||||
) {
|
||||
UpdatePopoverView(model: model)
|
||||
}
|
||||
.transition(.opacity.combined(with: .scale(scale: 0.95)))
|
||||
}
|
||||
let visible = !state.isIdle
|
||||
pillButton
|
||||
.popover(
|
||||
isPresented: $showPopover,
|
||||
attachmentAnchor: .rect(.bounds),
|
||||
arrowEdge: .top
|
||||
) {
|
||||
UpdatePopoverView(model: model)
|
||||
}
|
||||
.opacity(visible ? 1 : 0)
|
||||
.frame(width: visible ? nil : 0, height: visible ? nil : 0)
|
||||
.clipped()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue