Skip to content

fix: preview SQL popover not presenting from toolbar button#740

Merged
datlechin merged 1 commit intomainfrom
fix/preview-popover-disabled-button
Apr 14, 2026
Merged

fix: preview SQL popover not presenting from toolbar button#740
datlechin merged 1 commit intomainfrom
fix/preview-popover-disabled-button

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

The "Preview SQL" toolbar popover (eye icon / Cmd+Shift+P) never presents on macOS. Root cause: .popover(isPresented:) attached to a .disabled() button is silently ignored by SwiftUI — even when the binding is set programmatically.

Fix

Move .popover() from the disabled Button to an always-enabled VStack wrapper so SwiftUI can anchor the popover regardless of button state.

// Before — popover on disabled button, never presents
Button { ... }
    .disabled(!state.hasDataPendingChanges || ...)
    .popover(isPresented: $state.showSQLReviewPopover, attachmentAnchor: .point(.bottom)) { ... }

// After — popover on always-enabled wrapper, presents correctly
VStack {
    Button { ... }
        .disabled(!state.hasDataPendingChanges || ...)
}
.popover(isPresented: $state.showSQLReviewPopover) { ... }

Also removes attachmentAnchor: .point(.bottom) which caused incorrect anchor positioning in macOS toolbars.

Why this is correct

  • VStack with a single child is a layout no-op — identical frame as the button
  • .disabled() stays on the Button — native grayed-out appearance and VoiceOver semantics preserved
  • .help() stays on the Button — tooltip properly associated
  • Default popover anchor (.rect(.bounds)) works correctly in toolbars

Test plan

  • Connect to a database, open a table, edit a cell → click preview button → popover appears
  • Press Cmd+Shift+P → popover appears
  • Verify button is grayed out when no pending changes
  • Open Structure view → make a schema change → click preview → popover appears
  • Verify popover anchors correctly below the eye icon

Move .popover() from the disabled Button to an always-enabled VStack
wrapper so SwiftUI can anchor the popover regardless of button state.
Also remove attachmentAnchor: .point(.bottom) which caused incorrect
positioning in macOS toolbars.
@datlechin datlechin merged commit 1b3ffa0 into main Apr 14, 2026
2 checks passed
@datlechin datlechin deleted the fix/preview-popover-disabled-button branch April 14, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant