Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Paint iOS box shadows below child content - #60366

Draft
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/ios-box-shadow-paint-order
Draft

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/ios-box-shadow-paint-order

Conversation

@ide

@ide ide commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary:

A boxShadow draws over the view's children on iOS when the view has no border layer. RCTViewComponentView gives each shadow layer _borderLayer.zPosition. A view whose border Core Animation draws (no border, or a uniform border on a clipping view) has no border layer, so the shadow gets z-position 0. Children also have z-position 0, and the shadow layers are added after them, so the shadow paints on top. An inset ring that an opaque child should cover shows over the child instead, and an outset shadow covers the part of a child that overflows the view.

CSS paints box shadows above the element's background and below its border and content (css-backgrounds-3, "box-shadow"). This change gives the shadow layers a fixed z-position between the background layers (BACKGROUND_COLOR_ZPOSITION) and the border layer (BACKGROUND_COLOR_ZPOSITION + 1).

Two things change for a view without a border layer: an inset shadow is drawn below every child, and an outset shadow is drawn below a child that overflows the view, where it used to cover the overflowing part. Views that have a border layer already drew their shadows below the children. Their shadows now also sit below the border layer instead of level with it, which changes nothing visible: an outset shadow is masked to the outside of the border box and an inset one to the inside of the padding box.

Changelog:

[IOS] [FIXED] - Draw boxShadow below the view's children when the view has no separate border layer: an inset shadow no longer covers them, and an outset shadow no longer covers a child that overflows the view

Test Plan:

Ran:

node scripts/clang-format.js --check \
  packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm \
  packages/react-native/React/Tests/Mounting/RCTViewComponentViewTests.mm   # passes
git diff --check upstream/main                                              # clean

Run on this base (2026-11-28, Xcode 27.1, iOS 27.0 simulator):

xcodebuild -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme RNTester -configuration Debug \
  -destination 'generic/platform=iOS Simulator' ARCHS=arm64 ONLY_ACTIVE_ARCH=YES CODE_SIGNING_ALLOWED=NO build
xcodebuild test -workspace packages/rn-tester/RNTesterPods.xcworkspace -scheme React-RCTFabric-Unit-Tests \
  -destination 'platform=iOS Simulator,id=<iPhone 18 Pro>'
  • RNTester builds.
  • RCTViewComponentViewTests on this branch: 26 tests, 0 failures.
  • With RCTViewComponentView.mm from main and the test kept: testInsetBoxShadowIsBelowChildrenWithoutBorderLayer fails (0 is not less than 0).

React/Tests belongs to the React-RCTFabric pod's Tests test spec, which RNTester's Podfile does not install. To run it, I added :testspecs => ['Tests'] to the React-RCTFabric pod in scripts/cocoapods/fabric.rb, narrowed the test spec's source_files to this test file, and added an empty Swift file to the test spec so the bundle links the Swift runtime that RCTSwiftUI needs. None of that is part of this change. With the whole test spec, RCTSelectableParagraphComponentViewTests.mm does not compile in open source (react/renderer/element/ComponentBuilder.h not found).

Visual check still needed, in RNTester on a simulator before and after: a view with boxShadow: 'inset 0 0 0 8px black', no border, and an opaque child that fills it. Before, a black ring shows over the child; after, the child covers it. The same for an outset shadow (boxShadow: '0 0 0 8px black') with an opaque child that extends past the view's edge: before, the shadow shows over the overflowing part of the child; after, the child covers it.

🤖 Generated with Claude Code

A `boxShadow` drew over the view's children when the view had no border
layer. Each shadow layer copied `_borderLayer.zPosition`, and a view
whose border Core Animation draws (no border, or a uniform border on a
clipping view) has no border layer, so the shadow got z-position 0.
Children also have z-position 0 and the shadow layers are added after
them, so the shadow painted on top: an inset shadow over every child,
and an outset shadow over a child that overflows the view.

CSS paints box shadows above the element's background and below its
border and content
(https://drafts.csswg.org/css-backgrounds-3/#box-shadow). Give the
shadow layers a fixed z-position between the background layers and the
border layer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 28, 2026
@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 Nov 28, 2026
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 526db5e6511c.

android: no capture

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

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant