Skip to content

test: pin controller notify count for layout cycle (#122)#129

Merged
andyhorn merged 1 commit into
mainfrom
fix-layout-retrigger-issu
May 27, 2026
Merged

test: pin controller notify count for layout cycle (#122)#129
andyhorn merged 1 commit into
mainfrom
fix-layout-retrigger-issu

Conversation

@andyhorn
Copy link
Copy Markdown
Owner

Summary

Closes #122.

The issue asked whether the post-frame setRenderedSizes notify could be elided to avoid a layout retrigger. Investigation shows the notify is structurally required, not wasted:

  • It triggers the build-path switch in _buildForPhase from ResizableLayout (placeholder, non-interactive dividers) to Flex (interactive dividers with onResizeUpdate). Without it, dividers can't be dragged after the first layout.
  • notifyListeners() triggers markNeedsBuild, which is illegal during performLayout, so the post-frame defer is required.
  • controller.pixels is public API — user listeners legitimately expect to be notified when rendered pixels populate.
  • _needsLayout = false is set before the notify, so the resulting rebuild takes the Flex path and never re-enters layout. The "re-trigger" risk is already short-circuited.

Empirical measurement: 1 notify on initial mount, 2 notifies per hide() (one from setHidden, one from the post-frame setRenderedSizes). Both convey real state changes.

No lib/ changes. Adds two regression tests under a new notify count group that pin the cadence — a future refactor that accidentally adds a third notify or removes the load-bearing one will fail.

Test plan

  • initial mount notifies exactly once
  • hide produces exactly two notifies
  • Full test suite passes

🤖 Generated with Claude Code

Issue #122 questioned whether the post-frame setRenderedSizes notify
could be elided. Investigation shows it is structurally required: the
notify triggers the build-path switch from the layout widget (with
non-interactive placeholder dividers) to the flex widget (with
interactive dividers), and notifyListeners cannot legally run during
performLayout.

These tests pin the resulting notification cadence — one notify on
initial mount, two per hide — so a future refactor cannot silently
introduce a third redundant cycle or remove the load-bearing one.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@andyhorn andyhorn merged commit afc1130 into main May 27, 2026
1 check passed
@andyhorn andyhorn deleted the fix-layout-retrigger-issu branch May 27, 2026 13:42
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.

setRenderedSizes scheduled via addPostFrameCallback can re-trigger layout

1 participant