Skip to content

fix: keep a clicked popup open when glass draws behind its widget - #115

Merged
Seb-GRAF merged 1 commit into
stablebox:mainfrom
alexandrebucci:fix/glass-popup-anchor
Oct 20, 2026
Merged

Seb-GRAF merged 1 commit into
stablebox:mainfrom
alexandrebucci:fix/glass-popup-anchor

Conversation

@alexandrebucci

Copy link
Copy Markdown
Contributor

Problem

With Liquid Glass on (bar.glass.enabled), a popup opened by clicking a widget closes as soon as the pointer leaves the widget, so it can't be reached. It happens with any theme where a widget's background comes and goes, such as the menu-bar theme's hoverBackground with no resting background, or a background set only in the open state. With glass off, the popup stays open.

Changes

GlassBackground picked one of two view branches depending on whether the current color is visible: glass plus a color layer, or a plain background. Hover, open and data states change that color, so with glass on the modifier switched branches whenever the pointer entered or left a widget. SwiftUI then rebuilt the widget's subtree and dismantled its PopupAnchor, and dismantleNSView → WidgetPopup.removeAnchor closed the popup, even though it was pinned by the click.

With glass on, the modifier now keeps one view structure: it draws Glass.identity while the color is transparent and clear glass once it shows, with the color layer on top as before. The branch only depends on the macOS version and the glass settings, which don't change while the pointer moves. A transparent color still draws nothing, and a visible one draws exactly as before.

A side effect: hovering a widget with glass on no longer rebuilds its content each time the pointer enters or leaves it.

Testing

  • Instrumented a local build (logging WidgetPopup.close() with its call stack) and ran it on a scratch copy of a real configuration (menu-bar theme, glass on, a script widget with a popup) on macOS 26.6.2:
    • Before: 6 of 6 clicked popups closed when the pointer left the widget, each from PopupAnchor.dismantleNSView → removeAnchor → close(), and anchors were dismantled on almost every hover change.
    • After: popups stay open while moving onto them and using them; they close only on a click outside or a click on a row (dismissOnAction). No anchor was dismantled after launch.
  • New clickedPopupStaysOpenWhenItsWidgetBackgroundChanges(glass:): a widget whose only background comes from its open state, clicked in an offscreen bar. It fails without the fix for glass: true (the popup closes and loses its anchor) and passes with it; glass: false passes either way.
  • swift test: 327 tests pass on current main.
  • With the fix, the glass effect still shows on hovered widgets and in the popup.
  • Not checked: a pixel comparison of glass rendering before and after. Glass.identity draws no effect, and visible colors take the same glass and color layers as before.

Merging

One commit; any merge method keeps it in the changelog.

Claude Opus 5.5 via Claude Code

🤖 Generated with Claude Code

GlassBackground switched between two view branches whenever a widget's
background appeared or disappeared, such as when the pointer left a widget
with a hover background or its popup's open state set one. With Liquid
Glass on, SwiftUI rebuilt the widget, dismantled its popup anchor and
closed the popup. Glass now keeps one view structure and uses the identity
glass while the color is transparent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Seb-GRAF

Copy link
Copy Markdown
Collaborator

Thanks for the PR ❤️

@Seb-GRAF
Seb-GRAF merged commit f4d26dd into stablebox:main Oct 20, 2026
4 checks passed
Seb-GRAF added a commit that referenced this pull request Oct 20, 2026
fix: keep a clicked popup open when glass draws behind its widget
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.

3 participants