Skip to content

Resolve dynamic border and outline colors against the view trait collection in Fabric - #57837

Open
JacquesLeupin wants to merge 1 commit into
react:mainfrom
JacquesLeupin:fix/fabric-dynamic-border-color-trait-collection
Open

Resolve dynamic border and outline colors against the view trait collection in Fabric#57837
JacquesLeupin wants to merge 1 commit into
react:mainfrom
JacquesLeupin:fix/fabric-dynamic-border-color-trait-collection

Conversation

@JacquesLeupin

@JacquesLeupin JacquesLeupin commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Fixes #57836.

On Fabric, borderColor and outlineColor set from a dynamic color (PlatformColor / DynamicColorIOS) are converted to CGColor without an explicit trait-collection resolve, so they resolve against UITraitCollection.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 a traitCollectionDidChange: to heal them, so the wrong color persists. backgroundColor is unaffected because invalidateLayer already resolves it against self.traitCollection; Paper is unaffected because RCTView resolves border colors against the view's trait collection in displayLayer:.

This change applies the same treatment to the remaining color conversions in invalidateLayer:

  • the CoreAnimation border path (layer.borderColor),
  • RCTCreateRCTBorderColorsFromBorderColors (the border-image path), which now takes the view's trait collection,
  • both outlineColor paths.

Colors resolved with resolvedColorWithTraitCollection: are static, so the existing traitCollectionDidChange:invalidateLayer hook keeps them correct when the effective appearance changes. layer.shadowColor (in updateProps) 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 stock npx @react-native-community/cli init app (New Architecture, iOS Simulator with system Light): one DynamicColorIOS({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 via Appearance.setColorScheme('dark'), then mounts a second set of boxes under the override.

  • Before: fills turn green, but the borders of views already mounted when the override flips stay red (the light variant) on both border code paths, permanently — the trait-change invalidation re-runs invalidateLayer, but the conversion reads the ambient trait state. Recycled views reattached under the override stick the same way (no trait change at all).
  • After (this change applied to the app's node_modules/react-native and 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 overrideUserInterfaceStyle at launch, where every PlatformColor border previously rendered the system variant: borders now follow the app theme across launch-time override, runtime toggles, and recycled list views; React-RCTFabric compiles with no new warnings.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 5, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

1 participant