Commit 0c3452c
fix(FlexPanel): honor VerticalAlignment.Stretch as definite block axis (#176)
* fix(FlexPanel): honor VerticalAlignment.Stretch as definite block axis
FlexPanel's MeasureOverride keyed the block axis off the panel's
declared Height only — the parent's offer (availableSize.Height) was
ignored even when the panel's VerticalAlignment.Stretch + a finite
parent slot meant "fill". As a result the canonical web flex pattern
of header(auto) / body(flex:1) / footer(auto) filling a viewport
required a hardcoded .Height(N), and a flex:1 body would resolve to
an empty pool (basis:0 with no container size to grow into).
Changes:
- MeasureOverride: when no explicit Height, VerticalAlignment.Stretch,
and parent's offer is finite, treat block axis as definite. This is
the symmetric counterpart to the existing HorizontalAlignment.Stretch
inline-axis fill — same WinUI Stretch contract on both axes.
- ArrangeOverride: same opt-in reruns Yoga at finalSize.Height to
cover the case where the parent's arrange allocation differs from
the measure offer. _arranging suppresses child re-measure during
the rerun, preserving the resize-wobble fix from #172.
- MeasureFunction wrapper (the load-bearing piece): differentiate
Yoga's Exactly mode (true stretch-fit — pass finite to inner) from
AtMost / Undefined (basis / content phase — pass infinity). Without
this, a nested FlexPanel with default VerticalAlignment.Stretch
would treat AtMost's soft cap as a fill target and report the cap
as its DesiredSize, defeating the outer's flex-grow distribution
across siblings. With it, nested FlexPanels behave correctly under
any intermediate (Border, Grid, ContentControl, etc.) without a
parent-type sniff.
New self-test: Flex_HeaderBodyFooterFillsParentSlot covers the
canonical pattern under a Reactor host with no explicit .Height(N) on
the column — body resolves to slot − header − footer and overflowing
content scrolls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* review: address Copilot + agent reviews
Changes from review:
1. Revert MeasureFunction wrapper to original AtMost → finite mapping.
The earlier AtMost → infinity mapping broke TextBlock wrapping in
cross-axis flex layouts: Measure(width=∞) yields a 1-line tall
result; Measure(width=200) yields the correct wrapped multi-line
height. Yoga uses AtMost for FitContent sizing, so any wrapping
text under a non-Stretch align-items would have under-reported its
row height and clipped.
2. Move the nested-FlexPanel disambiguation to a [ThreadStatic]
_outerYogaHeightMode the wrapper publishes around child.Measure.
FlexPanel.MeasureOverride consults it to tell apart:
- WinUI AtMost from any non-Yoga parent → standard contract
(Stretch + finite = fill).
- Yoga AtMost from an outer FlexPanel doing basis/FitContent
measurement → soft cap, NOT a fill target. Treating it as fill
would make the inner report the cap as DesiredSize and defeat
the outer's flex-grow distribution across siblings.
- Yoga Exactly → stretch-fit allocation, fill.
This is what handles nested FlexPanels through any intermediate
(Border, Grid, ContentControl) without a brittle parent-type sniff.
3. Rename FlexColumnFillsParentSlot →
FlexHeaderBodyFooterFillsParentSlot to match the registry key
(Copilot review nit; matches grepability of other fixtures).
4. New self-test FlexBorderAutoHeightInflatesWithStretch documents
the known trade-off of measure-time fillBlockAxis: a Border with
auto-height around a default-Stretch FlexColumn inflates to the
parent's offer rather than shrink-wrapping. Asserts BOTH halves —
default Stretch inflates above 120px content, explicit
.VAlign(Top) shrink-wraps to 120px. If a future refactor lands web
flex semantics without inflating auto-height intermediates, the
inflate assertion should flip.
5. New self-test FlexAtMostPreservesTextWrapping verifies the
wrapper's AtMost handling didn't regress text wrapping. Long text
in a 200px column wraps to ≥ 40px height; under a broken
AtMost-as-infinity wrapper it would collapse to ~18px (1 line).
Test gates: 6819 unit tests pass, 670 selftests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 35f20a3 commit 0c3452c
3 files changed
Lines changed: 381 additions & 33 deletions
File tree
- src/Reactor/Yoga
- tests/Reactor.AppTests.Host/SelfTest
- Fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
297 | 312 | | |
298 | 313 | | |
299 | 314 | | |
| |||
325 | 340 | | |
326 | 341 | | |
327 | 342 | | |
328 | | - | |
329 | | - | |
330 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
331 | 386 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
339 | 396 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
347 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
348 | 417 | | |
349 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
350 | 424 | | |
351 | 425 | | |
352 | | - | |
| 426 | + | |
353 | 427 | | |
354 | 428 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
361 | 434 | | |
362 | 435 | | |
363 | 436 | | |
| |||
420 | 493 | | |
421 | 494 | | |
422 | 495 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
430 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
431 | 525 | | |
432 | 526 | | |
433 | | - | |
| 527 | + | |
434 | 528 | | |
435 | 529 | | |
436 | 530 | | |
| |||
551 | 645 | | |
552 | 646 | | |
553 | 647 | | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
554 | 663 | | |
555 | 664 | | |
556 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
557 | 675 | | |
558 | 676 | | |
559 | 677 | | |
| |||
0 commit comments