Resolve dynamic border and outline colors against the view trait collection in Fabric - #57837
Open
JacquesLeupin wants to merge 1 commit into
Open
Conversation
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.
Summary
Fixes #57836.
On Fabric,
borderColorandoutlineColorset from a dynamic color (PlatformColor/DynamicColorIOS) are converted toCGColorwithout an explicit trait-collection resolve, so they resolve againstUITraitCollection.currentTraitCollection— the system appearance. When the app's effective appearance differs from the system (Appearance.setColorScheme(...)/overrideUserInterfaceStyle), borders render the wrong variant, and views mounted while already attached under the override never get atraitCollectionDidChange:to heal them, so the wrong color persists.backgroundColoris unaffected becauseinvalidateLayeralready resolves it againstself.traitCollection; Paper is unaffected becauseRCTViewresolves border colors against the view's trait collection indisplayLayer:.This change applies the same treatment to the remaining color conversions in
invalidateLayer:layer.borderColor),RCTCreateRCTBorderColorsFromBorderColors(the border-image path), which now takes the view's trait collection,outlineColorpaths.Colors resolved with
resolvedColorWithTraitCollection:are static, so the existingtraitCollectionDidChange:→invalidateLayerhook keeps them correct when the effective appearance changes.layer.shadowColor(inupdateProps) shares the same latent flattening and could get the same treatment in a follow-up.Changelog:
[IOS] [FIXED] - Fabric: resolve dynamic (PlatformColor/DynamicColorIOS) border and outline colors against the view's trait collection instead of the system appearance
Test Plan
Runnable single-file RNTester reproducer for the issue: main...JacquesLeupin:react-native:repro/fabric-border-trait-collection-57836 (edits only
RNTesterPlayground.js). Equivalently, the reproducer from the linked issue as a stocknpx @react-native-community/cli initapp (New Architecture, iOS Simulator with system Light): oneDynamicColorIOS({light: red, dark: green})feeds a fill, a border on the border-image path, and a border on the CoreAnimation path; the app forces dark viaAppearance.setColorScheme('dark'), then mounts a second set of boxes under the override.invalidateLayer, but the conversion reads the ambient trait state. Recycled views reattached under the override stick the same way (no trait change at all).node_modules/react-nativeand rebuilt): every fill and border renders green, including the pre-override views once the trait-change invalidation runs against the view's own trait collection.Also verified as a patch on a production 0.81.5 New-Architecture app that applies its theme via
overrideUserInterfaceStyleat launch, where everyPlatformColorborder previously rendered the system variant: borders now follow the app theme across launch-time override, runtime toggles, and recycled list views;React-RCTFabriccompiles with no new warnings.