-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Shorthand CSS properties can cause style inconsistencies #8689
Comments
I think the underlying cause here is that I was not able to reproduce this issue in a unit test (using Jest) because Jsdom doesn't trickle down the effects like the major browser vendors seem to (eg updating This issue may not be worth fixing. It's kind of an edge case. The only ways to "fix" this that I can think of would be:
|
Overlapping styles are not allowed. The solutions are very costly and it was (AFAIK) decided that it is not reasonable to support it. Warnings would be very helpful but that hasn't be done yet. There are a number of issues discussing it if you're interested in more information. |
That's news to me. It may be the right decision but I don't think it's communicated clearly (at least not that I've seen). And it works most of the time which may lead someone to assume it's supported.
Fair enough. I was curious how costly |
Searching through React issues now I do see this mentioned a few other places (eg #5397 and #6348). When I first observed this issue it was related to |
Sorry to comment on an old and closed issue but is there no where currently open to discuss this issue? I'm facing it as demonstrated here https://codesandbox.io/s/elated-flower-zxvkf?file=/src/App.js and don't really like that "avoid using short-hand properties" is being pushed as an acceptable Developer Experience, especially for CSS enthusiasts. Border, for example, is an extremely common property. To avoid this issue I have to author my styles like this: borderWidth: '1px',
borderStyle: 'solid',
borderColor: 'blue' Instead of border: '1px solid blue' Whilst I understand there are costly performance issues meaning a solution is not viable, I'd still like the issue to be considered valid, and open (as I believe it is still valid, and it is not yet solved). Thanks. |
I'm reporting a bug.
What is the current behavior?
style
that contains both a shorthand CSS property and an over-writing longer form of the property (egoverflow
and a conflictingoverflowX
and/oroverflowY
property).overflow
) but remove the longer form property (egoverflowX
).Examples
This bug can be reproduced here: https://plnkr.co/edit/7O1xZUqbD13ST2BAxcm9?p=preview
Update: I have since updated the Plnkr to use
border
instead ofoverflow
since it makes the problem more immediately obvious to spot.Example
style={{ overflow: 'hidden', overflowY: 'auto' }}
style={{ overflow: 'hidden' }}
<div style="overflow: hidden;" />
<div style="overflow-x: hidden;" />
Alternate example
style={{ overflow: 'auto', overflowX: 'hidden', overflowY: 'hidden' }}
style={{ overflow: 'auto' }}
<div style="overflow: auto" />
<div style="" />
You can also reproduce this bug with properties like
margin
,padding
,border
, etc.Caveats
Note that if the shorthand value changes between renders things work as expected (because React explicitly updates the shorthand style).
I know this is very edge-case behavior and so may not be worth fixing. I originally noticed it by way of issue bvaughn/react-virtualized/issues/525.
Which versions of React / browser / OS are affected
This bug reproduces in Chrome, Firefox, and Safari using React 15.4.1 as well as the unreleased
ReactDOMFiber
renderer.The text was updated successfully, but these errors were encountered: