fix: Resize host view after graph height changes so menu re-measures#124
Open
pggpgg wants to merge 1 commit into
Open
fix: Resize host view after graph height changes so menu re-measures#124pggpgg wants to merge 1 commit into
pggpgg wants to merge 1 commit into
Conversation
The InfoViewController's view is installed as a custom view on an NSMenuItem (see ApplicationDelegate.applicationDidFinishLaunching). NSMenu measures the custom view once when the menu item is created and does not observe later Auto Layout changes. When the temperature graph becomes displayable, `update()` flips the graphViewHeight constraint from 0 to 100. Auto Layout grows the InfoViewController's view, but the menu item's host frame stays at the original (smaller) height, so the top of the graph and any other content above the bottom-anchored legend gets clipped off. Force a layout pass after the constraint change and propagate the new fitting size to view.frame so the menu re-measures the host item. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
430b509 to
4d591b1
Compare
pggpgg
added a commit
to pggpgg/Hot
that referenced
this pull request
May 19, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
|
Hey @macmade Apologies for the potentially clumsy PR, I'm not a professional. Found your project this week and I really appreciate what you've done with Hot. I experienced a weird visibility issue on Mac OS 26.5 (25F71) using my 13in M5 air, where the top half of the widget just clipped with the top of my screen. I thought I'd grab the repo and try a small targeted fix. This is the result. I used an assistant and the code may not be up to your standards, but I thought I'd bring it up to your attention nonetheless. Thanks and have a great day |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The temperature graph in the menu bar dropdown is clipped at the top: only the legend (orange dot + "Temperature" label) is visible at the bottom of the graph box, the sparkline above it gets cut off. Other rows in the same
InfoViewControllerstack view (Thermal Pressure, Temperature value, etc.) can also be clipped depending on layout state.Root cause
InfoViewController.viewis installed as a custom view on anNSMenuIteminApplicationDelegate.applicationDidFinishLaunching:NSMenumeasures the custom view's frame once at this point and caches the result for the menu item's host. It does not observe later Auto Layout changes to the view's intrinsic size.viewDidLoadinitializesgraphViewHeight.constant = 0, so the view is initially short. A couple of seconds later, once two temperature samples have been collected,update()does:Auto Layout grows the view to its new height, but the menu item's host frame stays at the original (smaller) value. The bottom-anchored portions of the graph (drawn at
rect.origin.yin unflipped coords — the orange dot and "Temperature" label) remain visible, while the top of the graph — including the sparkline — is clipped off by the menu item's container.Fix
After the constraint change in
update():view.layoutSubtreeIfNeeded()to flush the pending Auto Layout pass.view.frame.size = view.fittingSizeto nudgeNSMenuto re-measure the custom view's host item with the new size.This is the minimal change that gets the menu to respect the dynamic content size.
Test plan
🤖 Generated with Claude Code