Repository navigation
feat: FlexPanel (backport #1639) - #1658
Merged
Merged
Conversation
(cherry picked from commit 33bbf9e)
- Audit all 20 AutoLayout runtime test methods (~130 DataRow cases) against the CSS flexbox result: 2 of the 19 active tests are non-portable, both because of IsIndependentLayout - Correct the premise that AutoLayout's Padding is Figma-anchored — the alignment offsets add the raw padding back, so it reduces to CSS padding; verified against the asymmetric-padding test's asserted offsets - Record 4 mapping rules (Shrink=0, Grow+Basis=0, drop Spacing under SpaceBetween, re-measure at arrange finalSize) and 5 genuine gaps (G1-G5) - Recommend un-deferring MaxWidth/MaxHeight into v1 as a P0 decision - Add 4 mapping-rule guards to the tier-2 test list, and the negative-gap question to P1 - Add specs/lessons.md per AGENTS.md §3 with the lessons from this audit Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit fb99a9e)
Imports Meta's Yoga layout engine (Microsoft's C# line-port, MIT) as the foundation for a future FlexPanel control. AutoLayout is untouched. - 10 files into src/Uno.Toolkit.UI/Layout/Yoga/, pinned at microsoft/microsoft-ui-reactor v0.1.0-preview.13 (c9191b97). The WinUI adapter FlexPanel.cs is deliberately not vendored - it gets rewritten. - Namespace is Uno.Toolkit.UI.Yoga, not the spec's Uno.Toolkit.UI.Layout: that name collides with the existing public `enum Layout` in Uno.Toolkit.UI. The 6 public enums land in Uno.Toolkit.UI instead, as the future DP types; everything else was already internal upstream, so the added public surface is exactly those 6 types. - FlexLayoutDirection.LTR/RTL renamed to LeftToRight/RightToLeft. No numeric enum value is renumbered anywhere. - Every file carries a 4-line provenance header (repo, tag, commit, its own upstream path, import date, SPDX MIT with both copyright holders). Full license text in the new THIRD-PARTY-NOTICES.md. - build/scripts/import-yoga.py performs the whole transform. It is idempotent and self-verifying, so the next sync is a diff rather than an archaeology exercise. The scoped .editorconfig anticipated by the spec carries only indentation: the vendored code builds warning-free under TreatWarningsAsErrors, Nullable=enable and AnalysisModePerformance=AllEnabledByDefault as-is. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 9f5a49f)
The upstream generated suite is the reason the engine was imported rather than hand-written: it turns "we believe our flexbox is spec-correct" into evidence. Ported from the same pinned commit as the engine. 26 files, 590 test methods (544 active + 46 skipped upstream), 17,784 assertions. Result on desktop/Skia: 544 passed, 0 failed, ~6s. - xUnit to MSTest: [Fact] -> [TestMethod], [TestClass] inserted, Assert.Equal -> YogaAssert.Equal. - YogaAssert is the single float-comparison choke point. It keeps upstream's exact-equality semantics, but means a per-head rounding tolerance can be added in one place rather than 17,784. - 46 cases are GTEST_SKIP'd in Meta's own C++ suite and arrive already disabled; they import as [Ignore] to mirror that, not to deactivate anything of ours. Enabling them would import known-failing cases. - Upstream file, class and method names are kept verbatim, including the 5 classes whose names break Reactor's own Yoga* pattern, so a failure maps straight onto its upstream file. The README says so explicitly. Adds ~0.1s to a full rebuild of the runtime-test project. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 5e68bf8)
Adds specs/flexpanel-import/progress.md and folds four findings from the import back into the spec. - D2's namespace was unusable. Uno.Toolkit.UI.Layout collides with the existing public `enum Layout`; corrected to Uno.Toolkit.UI.Yoga plus Uno.Toolkit.UI for the 6 public enums. - G2 answered, as P1 required: Yoga clamps negative gap to 0 (ComputeGapForAxis ends in MaxOrDefined(x, 0)), so the loss of AutoLayout's negative Spacing is a real gap, reachable only via negative child Margin. - D7's analyzer containment proved unnecessary - the vendored code is warning-free as-is. NFR-5 restated: there was no upstream MIT header to preserve, so provenance comes from generated per-file headers plus THIRD-PARTY-NOTICES.md. - FR-8, P4 and risk 1 narrowed to the Skia heads, since Uno 7.0 removes the native targets. - Corpus size corrected from "~1,300 assertions" to the measured 590 tests / 17,784 assertions. Adds Facebook and SPDX to the cspell dictionary for the new docs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit f42211e)
CI runs the runtime tests unfiltered, so the filtered runs used to gate P2 were not sufficient evidence on their own. Unfiltered Release run on desktop/Skia: 874 passed, 0 failed, 57 skipped across 931 cases. Cross-checking every corpus method name against the result: 590/590 present (544 passed, 46 skipped, 0 missing), and the pre-existing 341 cases are unperturbed. The corpus adds ~6s to a 38s run. Also adds a scoped .editorconfig under Tests/Yoga/, mirroring the engine folder's. Without it the repo default (tabs) applies to 1.7 MB of 4-space vendored corpus, so a formatter run would silently rewrite it and destroy the upstream diff. YogaAssert.cs is carved out as ours. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit d796e0e)
- Add `FlexPanel`, a `Panel` that arranges its children with CSS Flexbox semantics on top of the vendored Yoga engine - Container properties: Direction, Wrap, JustifyContent, AlignItems, AlignContent, ColumnGap, RowGap, Padding, LayoutDirection - Attached properties: Grow, Shrink, Basis, FlexMinWidth, FlexMinHeight, AlignSelf, Position and the Left/Top/Right/Bottom insets - Cache Yoga nodes and attached-property reads per child, and reuse every collection across passes, so measure/arrange allocate nothing and stay LINQ-free - Add runtime tests covering container and attached-property layout, plus teardown/leak guards Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 3bec981)
- Add `FlexPanelSamplePage` under Controls, covering the container and per-child properties with static examples - Add `FlexPanelPlaygroundNestedPage`, an interactive surface reached through `Shell.ShowNestedSample`, exercising every FlexPanel property - Both pages are picked up by the shared project's `Content\**` glob, so no projitems change is needed Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 4cc425c)
- Add `doc/controls/FlexPanel.md` covering the container and attached properties, `Basis` vs `Width`, automatic minimum size, right-to-left, layout rounding and known limitations - List the page in `doc/toc.yml` under Controls - Cross-link from `AutoLayoutControl.md` so readers reproducing a CSS layout land on FlexPanel and Figma-parity users stay on AutoLayout Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 45dd461)
- Mark P3 (adapter) and P5 (sample + docs) done; log the 24 added runtime tests and the 898/898 unfiltered Release run on desktop/Skia - Record the deviations from upstream, including the `Get/SetFlexMinWidth` accessor-name fix that upstream's XAML would not bind against - Write up the scratch-collection leak the tier-3 tests caught and the `finally`-based hardening beyond it - Note P4 and spec risk 3 as still open — everything above is desktop/Skia only Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 6009725)
The vendored Yoga engine is compiled into Uno.Toolkit.WinUI.dll, but the
nupkg carried no license or notice file at all - verified by packing and
string-scanning the assembly (YogaAlgorithm, CalculateLayoutImpl and the
Uno.Toolkit.UI.Yoga namespace are all present in lib/net9.0). MIT requires
its copyright and permission notice to travel with "all copies or
substantial portions of the Software", and a compiled package is a copy.
The notice existed only in the repo, which does not reach consumers.
- Pack THIRD-PARTY-NOTICES.md into the Uno.Toolkit.WinUI package root.
Uno.Toolkit.WinUI is the only package that embeds the engine - verified
no Flex*/Yoga reference anywhere under src/library/.
- Attribute Controls/FlexPanel/{FlexPanel,FlexPanel.Properties}.cs. These
were described as "a rewrite, not a port", which is why they shipped
with no header. That was wrong: 52 of 58 identifiers match upstream,
including private helpers no independent implementation would pick
(SyncPointScaleLazy, IsScrollLikeContainer, ComputeMinContent,
ResolveMinDimension, SetRootConstraints), and bodies match closely -
SyncPointScaleLazy down to the 0.0001f epsilon. It is a derivative work
of MIT code, so attribution is required, not courtesy. The spec and
progress notes are corrected to say "adapted", not "rewritten".
- Credit Microsoft/Reactor in doc/controls/FlexPanel.md, which previously
named only Meta/Yoga.
Verified: the repacked nupkg contains THIRD-PARTY-NOTICES.md naming both
copyright holders and the pinned commit; Release build stays 0 warnings.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit a772df1)
- Cover FlexPanel.Padding at the control level: measure, content-sized DesiredSize, and the ArrangeOverride sizeChanged re-layout - Pick sizes so a double inset yields a different number (160 vs 120, 90 vs 130, 360 vs 320) rather than merely passing - Record in the D3 deviation row why the rename cannot double-count: Uno Panel.PaddingInternal is internal, non-virtual and never written by FlexPanel, and WinUI Panel has no Padding at all Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit d85e177)
- mark `ResolveMinDimension` static (CA1822). It reads no instance state, and as a warning-as-error it broke every build leg, not just one. - add `new` to `LayoutDirection`, which hides `View.LayoutDirection` on Android (CS0114). Android is the only target with a base member, so a bare `new` would raise CS0109 everywhere else; that is suppressed in targeted scope with a comment rather than an `#if` around the keyword. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 93acea2)
…l playground CodeQL flagged `IsChecked == true` / `!= true` as unnecessarily complex boolean expressions. Rewrite them as `is true` / `is not true`, matching the idiom already used in `GridExtensions` and `NavigationBar`. Semantics are unchanged for `bool?` - `null` still behaves as `false`. All 21 occurrences in the file are converted, not only the 9 the bot annotated, so the remainder do not resurface on the next scan. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 02bbf54)
Both Docs Validations legs were failing on files this branch adds. markdownlint: - LICENSE.md: drop the duplicate blank line left by the notice blockquote (MD012) - specs: tag four bare code fences as `text` (MD040) - Yoga README: reflow the wrapped list continuation that began with `+`, which markdown parsed as a nested list and made the file's real `-` bullets look inconsistent (MD004). The bullets were correct; the continuation line was the actual fault. cspell: - add `templateless` and `TFMs`, both repo vocabulary - reword `remappable`, `Upstreaming`, `checkmarks` and `unportable` rather than grow the shared dictionary with one-off coinages Also records the CS0109 wrinkle in specs/lessons.md: a platform-specific hide needs a fix that is correct on the platforms that do not see the base member either. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 281841f)
- 13 outcome-first recipes in the house .howto.md shape, ordered to lead with the four places CSS/WinUI intuition misleads: Basis vs Width, Grow="1" vs flex: 1 1 0, Shrink="0" overflow, and the FlexMinWidth="0" auto-min escape - every recipe is traced to an assertion in FlexPanelTests.cs rather than derived from the property tables, per the lesson recorded for AutoLayout.howto.md in specs/lessons.md - AlignContent, WrapReverse and the *Reverse directions are named in the quick reference but given no behavioral recipe: nothing at control level asserts them, so a snippet would be extrapolation - FlexPanel was one of three controls in doc/toc.yml without a walkthrough Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 9d963df)
- neither FlexPanel.md nor AutoLayoutControl.md linked to its own how-to, so the walkthroughs were reachable only through the site nav tree or search - one sentence each, no behavioral claims changed Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 101187b)
- adds FlexPanel to the "the library adds the following controls" list at the top of controls-styles.md, where every other shipped control appears - amends D6, which is otherwise unchanged: no Style, no theme resources, no Control Styles table row and no lightweight-styling.md keys still hold for a templateless panel. Dropping the control from the plain index as well was a side effect of that decision, not part of it Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 1e0af32)
- adds a P5b section covering the walkthrough, the toc entry, the reference cross-links and the controls-index amendment to D6 - notes that every recipe is pinned to a FlexPanelTests.cs assertion, and which properties were deliberately left without one - records the distribution gap left open: platform.uno/llms.txt indexes only unoplatform/uno and carries no uno.toolkit.ui URL, so no Toolkit walkthrough reaches that channel. Fixing it is a change to a different repo - adds llms to the cspell dictionary for the above Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit e0bc3fb)
- Move the preamble under the title instead of the last bullet - Point to unoplatform/uno instead of a local checkout path - Record the Generated/ and fixup-rebase lessons Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1a69b1f) # Conflicts: # specs/lessons.md
- Remove the LayoutDirection DP, its Android 'new' hide and the CS0109 pragma - Always run the engine left-to-right; FlowDirection mirrors the panel like any other - Replace the two LayoutDirection tests with a visual FlowDirection RTL check - Update the samples and docs, noting that Left/Right insets mirror as Canvas does Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 4d21738)
…ernal - Add FlexPanel's own FlexDirection/FlexWrap/FlexJustify/FlexAlign/FlexPositionType with XML docs, only the meaningful members, and the default value first - Map them onto the engine by name in FlexEnumMapping, falling back to the default - Make the vendored FlexEnums.cs internal via import-yoga.py, and fail the self-check on any public top-level type in the engine - Drop the inert FlexJustify.Auto/Stretch/Start/End, FlexAlign.Start/End and FlexPositionType.Static members, and FlexLayoutDirection from the public API Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit e2bcb90)
- Read the attached properties straight from the property system every pass - Remove _attachedCache, AttachedProps and the static detached-dirty table - Document why the node is dirtied unconditionally every pass Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit afefcee)
- A zero-width Measure clamps DesiredSize to 0, so the CSS 4.5 automatic minimum always resolved to 0 while still costing an extra measure per child - Remove ComputeMinContent / IsScrollLikeContainer; the minimum is now 0 unless FlexMinWidth / FlexMinHeight set one (the Yoga / React Native default) - FlexMinWidth / FlexMinHeight clamp their own physical axis; fix their docs - Replace the vacuous auto-min test with contract tests, and guard that each nesting level is measured once (was twice) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 1324781)
…dren - Replace the [ThreadStatic] mode, which reached every descendant, with an instance field the parent sets on a direct FlexPanel child only - Honor it only while the parent really is a FlexPanel - Invalidate the child when the mode changes at an unchanged constraint - Test: an inner panel under a Grid row fills that row's definite height Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 15117dd)
- Map a child's MaxWidth/MaxHeight onto the node, so grow and stretch stop there - Combine MinWidth/MinHeight with FlexMinWidth/FlexMinHeight (larger floor wins), so shrink stops there - Tests for grow past MaxWidth, shrink below MinWidth and stretch past MaxHeight Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 0a93266)
- XML docs on every DependencyProperty field - Record review amendments R1-R6 and the declined setter guards in the spec - Note the conformance corpus compiles into every sample head, WASM included - Add the review pass, with its measurements, to progress.md Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 06435fd)
Contributor
Author
|
Cherry-pick of 1a69b1f has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Contributor
|
|
- lessons: remove the committed conflict markers; keep the preamble and the #1639 lessons, drop main-only lessons (MSTest 4, Uno 7 retarget) - tests: mark FlexPanelTests and MeasureCountingFlexPanel partial, required by the Uno 6 source generators on net9.0-android/ios (CS0260) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Jw33s8JYQYQ2UxZbrtmeww
kazo0
approved these changes
Sep 30, 2026
Merged
1 task done
3 of 4 tasks
Merged
3 of 4 tasks
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.
GitHub Issue (If applicable): # n/a — tracked in internal issues, linked at the bottom
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The toolkit ships
AutoLayout, which mirrors the Figma AutoLayout frame and is intentionally scoped to that. Apps reproducing a CSS layout have no Flexbox primitive: there is noflex-grow/flex-shrink/flex-basisdistribution, no wrapping onto multiple lines, and nojustify-content/align-items/align-contentmatrix.What is the new behavior?
Adds
FlexPanel, aPanelthat arranges its children with CSS Flexbox semantics, backed by a vendored C# port of Meta's Yoga engine — so sizing, wrapping and distribution follow the CSS specification rather than an approximation of it.src/Uno.Toolkit.UI/Layout/Yoga/) — vendored from Reactor. Pure managedfloatmath: no platform API, no#if, no TFM-conditional code.src/Uno.Toolkit.UI/Controls/FlexPanel/) — a rewrite guided by upstream'sFlexPanel.cs, not a port. Container propertiesDirection,Wrap,JustifyContent,AlignItems,AlignContent,ColumnGap,RowGap,Padding,LayoutDirection; attached propertiesGrow,Shrink,Basis,FlexMinWidth,FlexMinHeight,AlignSelf,Positionand theLeft/Top/Right/Bottominsets. A child'sMargin,Width,HeightandVisibilityparticipate without any attached property.MeasureOverride/ArrangeOverrideallocate nothing and stay LINQ-free.total=898 passed=898 failed=0 skipped=57(874 → 898 is exactly the additions;skippedunchanged).UseLayoutRoundingtoggle, aFlowDirectiontoggle and a 200-child stress toggle.doc/controls/FlexPanel.md, atoc.ymlentry, and a cross-link fromAutoLayoutControl.mdso readers reproducing a CSS layout land onFlexPanelwhile Figma-parity users stay onAutoLayout.AutoLayoutis untouched:git diffagainst the fork point is empty forControls/AutoLayout/andTests/AutoLayoutTest.cs.Two deviations from upstream worth calling out:
Get/SetMinWidth→Get/SetFlexMinWidth. Upstream registers the DP as"FlexMinWidth"but names the accessorsGet/SetMinWidth; XAML resolves an attached property by accessor name, soutu:FlexPanel.FlexMinWidth="0"would not bind against upstream's naming.PointScaleFactoris bound toUseLayoutRoundingrather than being applied unconditionally, so the engine's pixel-grid snapping is opt-in and the platform's own rounding is what survives otherwise.Sanctioned warning suppression
FlexPanel.LayoutDirectionneedsnew: on Android the baseViewdeclares aLayoutDirectionof its own, so without it the Android build fails with CS0114. Android is the only target with a base member to hide, so a barenewraises CS0109 ("the new keyword is not required") on every other target — also an error, underTreatWarningsAsErrors.Per
AGENTS.md§4, the justification for the suppression is recorded here:#pragma warning disable CS0109brackets only that one property inFlexPanel.Properties.cs, with an explanatory comment, rather than wrapping the keyword in#if __ANDROID__(AGENTS.mddiscourages scattered#if).Hiding is behaviourally inert: Android's property is shadowed only for
FlexPanel-typed references, Uno's native layout code holdsView/ViewGroup-typed references, and XAML resolves the property throughLayoutDirectionProperty.PR Checklist
Please check if your PR fulfills the following requirements:
toc.ymlFlexPanel.md,AutoLayoutControl.mdcross-linkOther information
Draft — cross-platform validation is not done. Everything above was verified on desktop/Skia only. Still open before this can leave draft:
Both are tracked in the import spec under
specs/flexpanel-import/progress.md, which is committed here alongside the code and records the phase-by-phase results and reasoning.One real leak was caught by the teardown tests during development and fixed here: the scratch collections reused across layout passes were left populated after a pass, pinning children of a panel that never laid out again. The clears now sit in
finallyblocks and are repeated inOnUnloaded, so the release is unconditional rather than deferred to the next pass.Internal Issue (If applicable):
🤖 Generated with Claude Code
This is an automatic backport of pull request #1639 done by [Mergify](https://mergify.com).