Skip to content

A position: 'static' View's zIndex stacks nothing, where CSS stacks every flex item by its z-index #60350

Backlog

Description

@YevheniiKotyrlo

Description

A View whose position is 'static' ignores its zIndex: React Native draws it in tree order, so a later sibling that overlaps it covers it. In CSS every flex item whose z-index is not auto is stacked by that z-index as if it were positioned, whatever its position (css-flexbox-1; grid items the same, css-grid-2), and every in-flow child of a React Native View is a flex item. Chromium, Firefox and WebKit draw a position: static; z-index: 1 flex item over the later sibling it overlaps.

ConcreteViewShadowNode gives a View whose position type is static the order index 0 without reading its zIndex (ConcreteViewShadowNode.h L108-L113), and the mounting layer orders siblings by that index (sliceChildShadowNodeViewPairs.cpp L424-L425). Both are shared C++, so iOS orders the same way; I ran the reproducer on Android.

Fabric does this on purpose since 4d920fe7c99, whose summary reads "The standard says that zIndex should only be defined for non-static positioned views." That is CSS 2.1's rule (9.9.1: "Applies to: positioned elements"); for a flex item css-flexbox-1 makes z-index apply whatever its position, so the side effect is that a static View cannot be stacked at all.

Steps to reproduce

  1. Clone the reproducer and, with one Android device attached, run bash ./reproduce.sh. It builds and installs the release app, takes a screenshot and reads each row's colour where its two Views overlap. It exits 1 while the static row shows blue there, 0 once it shows red as the relative row does.

  2. Or by hand: build and install the release app (cd ReproducerApp && yarn install && cd android && ./gradlew assembleRelease && adb install -r app/build/outputs/apk/release/app-release.apk) and open it. Each row is a red 100x100 View with zIndex: 1 and marginRight: -50, followed by a blue 100x100 View; the first row's red View has position: 'static', the second's position: 'relative':

    <View style={{ flexDirection: 'row' }}>
      <View style={{ position: 'static', zIndex: 1, width: 100, height: 100, marginRight: -50, backgroundColor: 'red' }} />
      <View style={{ width: 100, height: 100, backgroundColor: 'blue' }} />
    </View>

Expected: red over blue where the two overlap, in both rows.
Seen: the relative row shows red over blue; the static row shows blue over red.

React Native Version

0.90.0-nightly-20261128-32260ddbe

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx @react-native-community/cli info

[…]
info Fetching system and libraries information...
System:
  OS: Windows 11 10.0.26300
  CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor          "
  Memory: 104.69 GB / 255.67 GB
Binaries:
  Node:
    version: 26.12.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: C:\Users\<user>\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 12.2.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.26100.0
IDEs:
  Android Studio: AI-262.9437.185.2621.16467767
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
    path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 22.0.0-alpha.0
    wanted: 22.0.0-alpha.0
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.90.0-nightly-20261128-32260ddbe
    wanted: 0.90.0-nightly-20261128-32260ddbe
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

MINGW64_NT-10.0-26300 x86_64, node v26.12.1, openjdk version "17.0.20.1" 2026-08-18 LTS
device: SM-S911B, Android 14 (API 34), arm64-v8a
react-native 0.90.0-nightly-20261128-32260ddbe
== ./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a
screenshot: screenshot.png
position: 'static', zIndex: 1: 450x300 px; at 25 dp: red; at 75 dp, where the two overlap: blue; at 125 dp: blue
position: 'relative', zIndex: 1: 450x300 px; at 25 dp: red; at 75 dp, where the two overlap: red; at 125 dp: blue
SUMMARY: the 'static' View's zIndex 1 stacks nothing: its later sibling covers it, where the 'relative' View with zIndex 1 stacks over it; exit 1

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/rn-static-view-zindex

Screenshots and Videos

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions