Skip to content

fix(core): reset inherited children when an InheritedProperty is unset - #11413

Draft
edusperoni wants to merge 1 commit into
mainfrom
fix/inherited-property-reset-cascade
Draft

edusperoni wants to merge 1 commit into
mainfrom
fix/inherited-property-reset-cascade

Conversation

@edusperoni

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

When an InheritedProperty (in core: bindingContext, iosOverflowSafeAreaEnabled, iosIgnoreSafeArea) is reset to its default on a node (unsetValue or 'initial'), descendants that had inherited the old value keep it. The cascade's reset branch in ui/core/properties/index.ts calls setFunc.call(child, unsetValue), but setFunc is the setter factory (valueSource) => function(value), so the call only builds and discards a setter and never writes to the child.

In practice this is reached through clearInheritedProperties() when a subtree is detached (ViewBase._parentChanged) and through Binding.updateTarget when a bindingContext binding resolves to null/undefined. InheritedCssProperty has the correct pattern (setDefaultFunc.call(childStyle, unsetValue)).

What is the new behavior?

The reset branch calls the concrete inherited setter (setInheritedValue.call(child, unsetValue)). Because the child's parent has just become ValueSource.Default, the child resolves to defaultValue with ValueSource.Default, fires its <name>Change event, and cascades to its own children. Children holding a local value are untouched, as before.

Side effect worth noting for reviewers: detaching a subtree now clears inherited view properties on all descendants (not just the removed root) and emits bindingContextChange on them during teardown. This matches what inherited CSS properties have always done; re-attaching re-propagates via propagateInheritableProperties. ListView item views receive bindingContext as a local value and are not affected.

Tests: ui/core/properties/inherited-property.spec.ts (6 cases: propagation, unsetValue reset, 'initial' reset, local descendant untouched, re-propagation after reset, end-to-end bindingContext reset on StackLayout/Label). Three of them fail without the fix.

Found while working on the property-change origin change (#11412).

The reset branch of the cascade called the setter factory `setFunc` instead of a
setter, so it built a new function and never wrote to the child. Descendants that
had inherited the old value kept it after the source was reset to its default.
@nx-cloud

nx-cloud Bot commented Sep 3, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit d5edbb4

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 4m 1s 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-03 19:18:22 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: d5edbb4

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