(cherry-pick) fix: Support optional arguments in boxShadow string (#7386) #7394
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.
Cherry pick of #7386
This PR updates the
parseBoxShadowString
function to handleboxShadow
strings with missing optional arguments (blurRadius
,spreadDistance
,color
).It now gracefully handles input like:
10px 10px white
(defaultsblurRadius
andspreadDistance
to0px
)10px 10px 5px white
(defaultsspreadDistance
to0px
)10px 10px
(defaults remaining values, uses black as color)The default happen on Native side where RN process it and defaults the missing values.
I've also added unit test with stripped string that make sure styles behave correctly.
I've also moved the string type check into the
processBoxShadow.js
file, since we want to supportboxShadow
values that are arrays of objects where individual properties can be strings with units. (The possibility to support this was already implemented buttypeof newValue.boxShadow === 'string'
prevented it from existing)Test plan
Example Code
Summary
Test plan