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:
Lawrence Chen 2026-02-08 19:16:07 -08:00
parent 498cc6e4bc
commit 59370115ce

View file

@ -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