← 输入框|github.com|刷新
Skip to content

fix(ios): skip Switch color updates without a native view - #11579

Open
NathanWalker wants to merge 1 commit into
mainfrom
fix/ios-switch-disposed-color
Open

NathanWalker wants to merge 1 commit into
mainfrom
fix/ios-switch-disposed-color

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

On iOS, Switch.setNativeBackgroundColor writes straight to nativeViewProtected. When checked changes while the Switch has no native view, which happens with framework renderers setting properties around creation or disposal, the call throws TypeError: Cannot set property 'onTintColor' of null (#10101). On iOS 26+ the color update also runs from a setTimeout after the toggle animation, so it can fire after the view is gone. The deferred corner-radius update in the same method already guarded against this; the main path didn't.

What is the new behavior?

setNativeBackgroundColor returns early when there's no native view. Colors are still applied the next time the native view exists, through the normal property sync.

The new spec ui/switch/index.ios.spec.ts covers the missing-view case and a live-view color application. The missing-view case fails without the fix. The full core suite passes (553 tests).

Closes #10101.

@nx-cloud

nx-cloud Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit ff2afa4

Command Status Duration Result
nx run-many -t build -p core,webpack5,vite ✅ Succeeded 23s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-10-23 20:06:14 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: ff2afa4

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.

[iOS] Possible race condition when setting Switch background color

1 participant