From 4d591b1ab88986231f237816aca84eda1323bde0 Mon Sep 17 00:00:00 2001 From: pggpgg Date: Tue, 19 May 2026 16:02:02 -0400 Subject: [PATCH] fix: Resize host view after graph height changes so menu re-measures 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) --- Hot/Classes/InfoViewController.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Hot/Classes/InfoViewController.swift b/Hot/Classes/InfoViewController.swift index 22f1944..035cce9 100644 --- a/Hot/Classes/InfoViewController.swift +++ b/Hot/Classes/InfoViewController.swift @@ -152,7 +152,22 @@ public class InfoViewController: NSViewController self.graphView?.addData( speed: 100, temperature: self.temperature ) } - self.graphViewHeight.constant = self.graphView?.canDisplay ?? false ? 100 : 0 + let newGraphHeight: CGFloat = self.graphView?.canDisplay ?? false ? 100 : 0 + + if self.graphViewHeight.constant != newGraphHeight + { + self.graphViewHeight.constant = newGraphHeight + + // The InfoViewController's view is hosted inside an NSMenuItem (see + // ApplicationDelegate.applicationDidFinishLaunching). NSMenu measures + // the custom view once and does not observe later Auto Layout changes, + // so when the graph height flips from 0 -> 100 the menu item's host + // frame stays at the original (smaller) size and clips the top of the + // graph. Force a layout pass and propagate the new fitting size to the + // view's frame so the menu picks up the change. + self.view.layoutSubtreeIfNeeded() + self.view.frame.size = self.view.fittingSize + } self.onUpdate?() }