Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A box that grows, a Scroll or List along its scroll axis and each box around one that sets no size on that axis now shrink by default, so a list or scroll view scrolls however deep it sits instead of stretching the boxes around it past the window. Other boxes, a Scroll's content included, keep their size. BREAKING CHANGE: core.Style.FlexShrink is a core.FlexShrink instead of a float32. Write FlexShrink: core.NoShrink for FlexShrink: 0 where a growing or scrolling box must keep its size, FlexShrink: core.Shrink(n) for any other factor, and drop FlexShrink: 1 beside FlexGrow: 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@houko could you review this one with me? It is a key change: the default layout locks scrolling as soon as any box sits between the window and a list, which every app migrating to NSGo has hit, and this fixes it at the root. But it breaks users hard: 🤖 Claude Opus 5.5 |
houko
left a comment
There was a problem hiding this comment.
The approach is right and I could not find a case where the new defaults lay out wrongly. I traced the invalidation paths of syncScrollAxes / defaultFlexShrink: a parent's Direction flip and a Scroll.Horizontal change drop the children's cached styles, place and Holder.show call dropLayoutStyles, hoisted roots (modals, overlays, accessories, PiP) all go through layoutRoot, which syncs first, and relayoutBoundaries syncs before Relayout. A boundary has point sizes on both axes, so it never exposes a scroll axis and cannot leave its parent's default stale. Requesting changes for the CI failures and the missing tests.
Blocking
- Go formatting fails on
tsx/stylekeys_test.go: the map keys need realigning after the type change.gofmt -w tsx/stylekeys_test.go. test-suite (core)fails onTestRepositoryFragmentsbecause of### Breaking; expected until #2736 lands, as the description says. Keep the merge order.
Should change
- Tests cover only the static nesting.
core/layout_test.goadds one test, and the part most likely to regress is the cached bitmask on incremental updates, whichlayoutDirtypruning skips. Each of these should assert that the list still scrolls after the update:- a parent's
Directionswitching between row and column; Scroll.Horizontaltoggling;- a wrapper around a
Listmoved to another parent; - a wrapper around a
Listinside a modal or overlay; - a
Scrollmounted into, and removed from, a tree that has already been laid out.
- a parent's
layout.Boundaryis relaxed without a mention. A box with point sizes and a nonzero shrink now counts as a relayout boundary when bothMinSizes are points. With no automatic minimum sizes nothing inside can change its size, so I believe it is correct, but it changes incremental layout on its own. Please say so in the description and add a test: such a boundary keeps the right size after a sibling changes.FlexShrink.Value()returns 0 when unset, while the factor in effect may be 1. A tool that reads it, such as an inspector or a serializer, reports the wrong number. Either document it as the explicit factor only, or dropValue()from the exported API.
Worth noting
- A growing box now shrinks by default. In a column, a
FlexGrow: 1box whose content is taller than the window used to grow and push the following siblings off screen; now it shrinks to fit and its content overflows onto them, a footer for example. The breaking note says growing boxes shrink, but the migration text should name this consequence: such content needsOverflowor aScrollaround it. - When mounting on
body, the web host now sets inlinewidth/height: 100%onhtmlandbodyandmargin: 0onbody, which overrides a page's own CSS for them. It is a separate commit with a different reach from the rest of the PR; consider splitting it out.
Summary
Screens written the obvious way stop scrolling:
FlexShrinkdefaulted to 0, so anycore.Viewbetween the window and acore.Scrollorcore.List, such ascore.View{Style: core.Style{FlexGrow: 1}}or a bare wrapper, grew to the list's full height and the list had nothing left to scroll. Three apps hit it while migrating, and NSGo's ownexamples/previews, the preview host,ui/filepickerandbase/dockcarried the same mistake.Now a box that grows, a
ScrollorListalong its scroll axis, and each box around one that sets no size on that axis shrink by default, so a list scrolls however deep it sits. Every other box keeps its size, aScroll's content included, so headers, tabs, toolbars and sidebars beside a list are not squeezed: shrinking everything, as CSS does, squashed them, since NSGo has no automatic minimum sizes to stop it.Breaking:
core.Style.FlexShrinkbecomes acore.FlexShrinkset withcore.Shrink(n)orcore.NoShrink, so the oldFlexShrink: 0andFlexShrink: 1no longer compile instead of silently changing meaning. Apps writecore.NoShrinkfor0where a growing or scrolling box must keep its size,core.Shrink(n)for other factors, and dropFlexShrink: 1besideFlexGrow: 1.core/layout.goresolves the default (defaultFlexShrink), with a scroll-axis bitmask kept per node for the dirty subtree before each layout (syncScrollAxes); reparenting drops cached layout styles.FlexShrinkin the repository is migrated, Tailwind'sshrink-*and TSX'sflexShrinkincluded.docs/architecture/core.md,layout.mdin every language,skills/nsgo/SKILL.md.The changelog fragment uses
### Breaking, which #2736 adds: merge #2736 first, then this after a rebase, ortools/changelog checkfails.Targets
core,base,ui,tsx, thensgotool)Screenshots
The gallery's pages lay out as on main at desktop and phone sizes, compared view by view for overflowing or squashed boxes, except Plot's last x-axis label, which now stays inside the plot instead of running past its end.
Verification
go tool nsgo check, andgo tool nsgo check -target allbefore the last round of changesgo tool nsgo test: 5458 passed;TestInputMethodCommitAndSinkCandidatestimed out waiting for the test window to take keys and passed on its own, and the fixedTestListsTabsAndSidebarSearchKeepHeightpasses. The changelog check needs feat(changelog): group release notes under breaking changes, highlights, features and bug fixes #2736.go tool nsgo test -target <target>on the targets aboveChecklist
fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.changelog.d/fragment, not inCHANGELOG.md.🤖 Claude Opus 5.5
🤖 Generated with Claude Code