-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement proper css styles order of precedence #2744
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 5ccd0c4:
|
The description of the problem here is not very clear, but I can see from the unit tests that this patch is incorrect. The current behavior is how React Native works. Read the docs for more info https://necolas.github.io/react-native-web/docs/styling/#how-it-works |
Yeah thank you for the link! I missed that part, thank you! |
That's because you're using inline styles, which aren't 100% equivalent to RN. Use static styles. This is 100% not going to change because it's by design, and for good reasons already explained in the docs. Thanks |
Generally I was try to fix the issue like this.
The thing was that after preprocessing styles and replacing non standard to standard css styling properties, the order of styles changed. For example initial style
was converted to
So it lost initial style order and created new nextStyle object by dynamically adding properties, but in alphabetical order.
My solution is to 'destruct' (convert from long form to short). For example paddingVertical: 10 is converted into two properties: paddingTop and paddingBottom and only this properites is added to the final nextStyle object. This will automatically merge/override same style properties and emulate original web css stylinf behaviour (last added properties is applied). So in the end after preprocessing I got this styles for this case:
To demonstarate the issue I've also created a snack.