@@ -55,7 +55,7 @@ exports[`components/Pressable hover interaction 2`] = `
exports[`components/Pressable hover interaction 3`] = `
@@ -63,14 +63,14 @@ exports[`components/Pressable hover interaction 3`] = `
exports[`components/Pressable press interaction (keyboard) trigger press when keyup is on the same element 1`] = `
`;
exports[`components/Pressable press interaction (keyboard) trigger press when keyup is on the same element 2`] = `
@@ -84,14 +84,14 @@ exports[`components/Pressable press interaction (keyboard) trigger press when ke
exports[`components/Pressable press interaction (pointer) 1`] = `
`;
exports[`components/Pressable press interaction (pointer) 2`] = `
@@ -103,7 +103,7 @@ exports[`components/Pressable press interaction (pointer) 2`] = `
exports[`components/Pressable press interaction (pointer) 3`] = `
@@ -112,7 +112,7 @@ exports[`components/Pressable press interaction (pointer) 3`] = `
exports[`components/Pressable prop "accessibilityLabel" value is set 1`] = `
`;
@@ -120,14 +120,14 @@ exports[`components/Pressable prop "accessibilityLabel" value is set 1`] = `
exports[`components/Pressable prop "accessibilityLiveRegion" value is set 1`] = `
`;
exports[`components/Pressable prop "accessibilityRole" value alters HTML element 1`] = `
@@ -135,7 +135,7 @@ exports[`components/Pressable prop "accessibilityRole" value alters HTML element
exports[`components/Pressable prop "accessibilityRole" value is "button" 1`] = `
@@ -153,14 +153,14 @@ exports[`components/Pressable prop "accessibilityRole" value is set 1`] = `
exports[`components/Pressable prop "disabled" 1`] = `
`;
exports[`components/Pressable prop "href" 1`] = `
@@ -168,7 +168,7 @@ exports[`components/Pressable prop "href" 1`] = `
exports[`components/Pressable prop "nativeID" value is set 1`] = `
@@ -176,14 +176,14 @@ exports[`components/Pressable prop "nativeID" value is set 1`] = `
exports[`components/Pressable prop "pointerEvents" 1`] = `
`;
exports[`components/Pressable prop "style" value is set 1`] = `
@@ -191,7 +191,7 @@ exports[`components/Pressable prop "style" value is set 1`] = `
exports[`components/Pressable prop "testID" value is set 1`] = `
diff --git a/packages/react-native-web/src/exports/ScrollView/__tests__/__snapshots__/index-test.js.snap b/packages/react-native-web/src/exports/ScrollView/__tests__/__snapshots__/index-test.js.snap
index 7ecce488e..d68c66360 100644
--- a/packages/react-native-web/src/exports/ScrollView/__tests__/__snapshots__/index-test.js.snap
+++ b/packages/react-native-web/src/exports/ScrollView/__tests__/__snapshots__/index-test.js.snap
@@ -2,22 +2,22 @@
exports[`components/ScrollView prop "centerContent" with 1`] = `
`;
exports[`components/ScrollView prop "centerContent" without 1`] = `
`;
@@ -27,11 +27,11 @@ exports[`components/ScrollView prop "refreshControl" with 1`] = `
id="refresh-control"
>
@@ -39,11 +39,11 @@ exports[`components/ScrollView prop "refreshControl" with 1`] = `
exports[`components/ScrollView prop "refreshControl" without 1`] = `
`;
diff --git a/packages/react-native-web/src/exports/Switch/__tests__/__snapshots__/index-test.js.snap b/packages/react-native-web/src/exports/Switch/__tests__/__snapshots__/index-test.js.snap
index deda1cf15..2723e3db5 100644
--- a/packages/react-native-web/src/exports/Switch/__tests__/__snapshots__/index-test.js.snap
+++ b/packages/react-native-web/src/exports/Switch/__tests__/__snapshots__/index-test.js.snap
@@ -2,42 +2,42 @@
exports[`components/Switch disabled when "true" and value="false", a disabled checkbox is rendered with provided false value of trackColor 1`] = `
`;
exports[`components/Switch disabled when "true" and value="false", a disabled checkbox is rendered with provided thumbColor 1`] = `
`;
exports[`components/Switch disabled when "true" and value="false", a disabled checkbox is rendered with provided trackColor 1`] = `
`;
exports[`components/Switch disabled when "true" and value="true", a disabled checkbox is rendered with provided activeThumbColor 1`] = `
`;
exports[`components/Switch disabled when "true" and value="true", a disabled checkbox is rendered with provided activeTrackColor 1`] = `
`;
exports[`components/Switch disabled when "true" and value="true", a disabled checkbox is rendered with provided true value of trackColor 1`] = `
`;
diff --git a/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap b/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap
index 0f8c7a4bc..c4a0adfd7 100644
--- a/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap
+++ b/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap
@@ -2,16 +2,16 @@
exports[`components/View default 1`] = `
`;
exports[`components/View non-text is rendered 1`] = `
@@ -20,41 +20,41 @@ exports[`components/View non-text is rendered 1`] = `
exports[`components/View prop "aria-label" value is set 1`] = `
`;
exports[`components/View prop "aria-labelledby" value is set 1`] = `
`;
exports[`components/View prop "aria-live" value is set 1`] = `
`;
exports[`components/View prop "dir" value is "ltr" 1`] = `
`;
exports[`components/View prop "dir" value is "rtl" 1`] = `
`;
exports[`components/View prop "href" href with accessibilityRole 1`] = `
@@ -62,27 +62,27 @@ exports[`components/View prop "href" href with accessibilityRole 1`] = `
exports[`components/View prop "href" value is set 1`] = `
`;
exports[`components/View prop "hrefAttrs" null values are excluded 1`] = `
`;
exports[`components/View prop "hrefAttrs" requires "href" 1`] = `
`;
exports[`components/View prop "hrefAttrs" target variant is set 1`] = `
@@ -90,7 +90,7 @@ exports[`components/View prop "hrefAttrs" target variant is set 1`] = `
exports[`components/View prop "hrefAttrs" value is set 1`] = `
@@ -108,7 +108,7 @@ exports[`components/View prop "lang" ar 1`] = `
exports[`components/View prop "lang" fr 1`] = `
@@ -116,13 +116,13 @@ exports[`components/View prop "lang" fr 1`] = `
exports[`components/View prop "lang" undefined 1`] = `
`;
exports[`components/View prop "lang" with dir 1`] = `
@@ -130,27 +130,27 @@ exports[`components/View prop "lang" with dir 1`] = `
exports[`components/View prop "nativeID" value is set 1`] = `
`;
exports[`components/View prop "pointerEvents" 1`] = `
`;
exports[`components/View prop "role" value alters HTML element 1`] = `
`;
exports[`components/View prop "role" value is "button" 1`] = `
@@ -158,21 +158,21 @@ exports[`components/View prop "role" value is "button" 1`] = `
exports[`components/View prop "role" value is set 1`] = `
`;
exports[`components/View prop "style" value is set 1`] = `
`;
exports[`components/View prop "testID" value is set 1`] = `
`;
diff --git a/packages/react-native-web/src/exports/View/__tests__/index-test.js b/packages/react-native-web/src/exports/View/__tests__/index-test.js
index 173644c4a..0df149cf2 100644
--- a/packages/react-native-web/src/exports/View/__tests__/index-test.js
+++ b/packages/react-native-web/src/exports/View/__tests__/index-test.js
@@ -307,4 +307,16 @@ describe('components/View', () => {
expect(container.firstChild).toMatchSnapshot();
});
});
+
+ describe('default styles', () => {
+ test('default zIndex should be "auto" not 0', () => {
+ // Using 'auto' instead of 0 prevents creating a new CSS stacking context,
+ // which allows nested Views with z-index to layer correctly relative to
+ // elements outside the View hierarchy
+ const { container } = render(
);
+ const element = container.firstChild;
+ const computedStyle = window.getComputedStyle(element);
+ expect(computedStyle.zIndex).toBe('auto');
+ });
+ });
});
diff --git a/packages/react-native-web/src/exports/View/index.js b/packages/react-native-web/src/exports/View/index.js
index cec4d5826..239a6dfbb 100644
--- a/packages/react-native-web/src/exports/View/index.js
+++ b/packages/react-native-web/src/exports/View/index.js
@@ -163,7 +163,7 @@ const styles = StyleSheet.create({
padding: 0,
position: 'relative',
textDecoration: 'none',
- zIndex: 0
+ zIndex: 'auto'
},
inline: {
display: 'inline-flex'