Repository navigation
Conversation
Visual regressionNo visual differences at android: no capture |
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 inset shadows above the element's background and all box shadows below its border and content (https://drafts.csswg.org/css-backgrounds-3/#shadow-layers). Give the shadow layers a fixed z-position between the background layers and the border layer. Outset shadows then sit above the background, but they are masked to the outside of the border box. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
ide
force-pushed
the
@ide/ios-box-shadow-paint-order
branch
from
November 29, 2026 12:01
526db5e to
3c058a2
Compare
This branch has not been deployed
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:
On iOS a
boxShadowdraws over the view's children when the view has no border layer, as a view with no border does. Each shadow layer gets_borderLayer.zPosition, so without a border layer it gets 0, the same as the children, and it is added after them. An inset ring that an opaque child should cover shows over the child, and an outset shadow covers the part of a child that overflows the view.CSS paints box shadows below the element's content: inset shadows immediately above its background and below its border, outset shadows immediately below its background (css-backgrounds-3). This change gives the shadow layers a fixed z-position between the background layers (
BACKGROUND_COLOR_ZPOSITION) and the border layer. Outset shadows therefore sit above the background, unlike CSS, but they are masked to the outside of the border box, where there is no background, so the difference is not visible.Views with a border layer already drew shadows below the children; their shadows now sit just below the border layer instead of level with it, which is not visible either, since an inset shadow is masked to the inside of the padding box.
Changelog:
[IOS] [FIXED] - Draw
boxShadowbelow 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 viewTest Plan:
testInsetBoxShadowIsBelowChildrenWithoutBorderLayerinRCTViewComponentViewTestsis new. WithRCTViewComponentView.mmfrommainit fails (0is not less than0). Run with Xcode 27.1 on an iOS 27.0 simulator; RNTester builds:RNTester's Podfile does not install the
React-RCTFabricTeststest spec. To run it (locally, not in this change): add:testspecs => ['Tests']to that pod inscripts/cocoapods/fabric.rb, narrow the test spec'ssource_filesto this test file (RCTSelectableParagraphComponentViewTests.mmdoes not compile in open source), and add an empty Swift file to it so the bundle links the Swift runtimeRCTSwiftUIneeds.Not checked on screen. In RNTester, take a view with no border and an opaque child. With
boxShadow: 'inset 0 0 0 8px black'and a child that fills the view, a black ring shows over the child before and not after. WithboxShadow: '0 0 0 8px black'and a child that extends past the view's edge, the shadow shows over the overflow before and not after.