Skip to content

Commit 691f01d

Browse files
kirandashshuding
andauthored
fix: handle z-index as unitless property (#667)
## Description ### Current behavior: When setting z-index values in styles, a warning appears stating "Expected style 'zIndex: 1px' to be unitless". This warning is incorrect since z-index should be handled as a unitless property. While z-index has no effect in SVG (as elements are painted in document order), the warning itself needs to be fixed for better developer experience. ### Changes in this PR: - Added special case handling for `zIndex` property - Added clear warning message explaining that z-index is not supported in SVG - Improved developer experience by providing more accurate feedback about SVG limitations Closes #660 ## Test plan ### Before The floating warning appears in console when setting z-index: ```javascript style={{ zIndex: 1 }} ``` Shows warning: "Expected style 'zIndex: 1px' to be unitless" ![image](https://github.com/user-attachments/assets/4833bbb7-4794-4c05-baff-bab6c645399e) ### After 1. Set z-index in styles 2. Verify the correct warning appears: "z-index is not supported in SVG. Elements are painted in the order they appear in the document." 3. Test with different z-index values 4. Verify the warning is clear and helpful for developers ![image](https://github.com/user-attachments/assets/caf51676-85f4-429d-a687-4c3e65a9d063) --------- Co-authored-by: Shu Ding <[email protected]>
1 parent 5945f7a commit 691f01d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/handler/expand.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ function handleSpecialCase(
5959
value: string | number,
6060
currentColor: string
6161
) {
62+
if (name === 'zIndex') {
63+
console.warn(
64+
'`z-index` is currently not supported.'
65+
)
66+
return { [name]: value }
67+
}
68+
6269
if (name === 'lineHeight') {
6370
return { lineHeight: purify(name, value) }
6471
}

0 commit comments

Comments
 (0)