Skip to content

feat(windows): let a parent resolve its children's percentage sizes - #11468

Open
triniwiz wants to merge 1 commit into
feat/windowsfrom
fix/windows-parent-percent-sizing
Open

triniwiz wants to merge 1 commit into
feat/windowsfrom
fix/windows-parent-percent-sizing

Conversation

@triniwiz

@triniwiz triniwiz commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

PR Checklist

What is the current behavior?

On Windows, a percentage width/height is resolved by the view itself:

  • Below 100%: after each SizeChanged, a deferred pass sets Width = parent.ActualWidth * pct.
  • 100%: becomes Stretch alignment.

A parent that lays out its children with its own engine can't use that. The value ignores the parent's padding and the child's position in a row, and Stretch can't express 100% of a row item or a percentage height. The explicit XAML Width also overrides whatever size the parent's layout gives the child.

What is the new behavior?

The Windows View gains _setChildPercentSize(child, horizontal, fraction): boolean, which returns false by default. It's declared, Windows-only, in index.d.ts. A view with a percentage width or height hands it to its parent's _setChildPercentSize. When that returns true:

  • XAML size: Width/Height stay unset.
  • Core's own sizing: skipped (no size watch, no Stretch, no flex-basis percent).

Setting a length later calls it again with null to clear it. Every existing parent uses the default, so their behavior doesn't change.

Related: triniwiz/nativescript-mason#67 overrides it for its layouts.

Testing: tested on Windows x64 with that branch, covering 50% in a row, 100% × 100% in a row, 50% height with margins in a fixed-height column, and 75% of a grid cell. All resolve against the containing block. tsc -p packages/core/tsconfig.lib.json reports no errors. There are no specs for the Windows view.

@nx-cloud

nx-cloud Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 7d0adce

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 36s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-28 13:21:44 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11468
npm i https://pkg.pr.new/@nativescript/vite@11468
npm i https://pkg.pr.new/@nativescript/webpack@11468

commit: 7d0adce

View gains _setChildPercentSize(child, horizontal, fraction), which
returns false. A percentage width or height is handed to the parent's;
when it returns true, core leaves the XAML Width/Height unset and skips
its own percent sizing. Setting a length clears it (fraction null).

This branch has not been deployed

No deployments
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.

1 participant