Closed
Description
I'm reporting a bug.
What is the current behavior?
- Render a host component with a
style
that contains both a shorthand CSS property and an over-writing longer form of the property (egoverflow
and a conflictingoverflowX
and/oroverflowY
property). - Update the host component (re-render) with the same shorthand property (eg
overflow
) but remove the longer form property (egoverflowX
). - The host component style is now invalid.
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 of overflow
since it makes the problem more immediately obvious to spot.
Example
- Render
style={{ overflow: 'hidden', overflowY: 'auto' }}
- Render
style={{ overflow: 'hidden' }}
- Expected:
<div style="overflow: hidden;" />
- Actual:
<div style="overflow-x: hidden;" />
Alternate example
- Render
style={{ overflow: 'auto', overflowX: 'hidden', overflowY: 'hidden' }}
- Render
style={{ overflow: 'auto' }}
- Expected:
<div style="overflow: auto" />
- Actual:
<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.