carbon-addons-iot-react
carbon-addons-iot-react copied to clipboard
[DashboardEditor] react-grid-layout 1.2.3 breaks click behavior
What package is this for?
- [x ] React
Describe the bug
Upgrading past react-grid-layout
version 1.2.2
causes the DashboardEditor tests to fail as soon as a card is clicked. The error that is thrown is a <DraggableCore> not mounted on DragStart!
and is described/demonstrated further in this issue, and is due to the following change in react-grid-layout
:
React-Grid-Layout is now fully compatible with <React.StrictMode>.
- Usage of ReactDOM has been removed by using React.createRef() inside `react-grid-layout`, and the new nodeRef prop in react-draggable.
To Reproduce
Steps to reproduce the behavior:
- Try updating to
react-grid-layout
1.2.3 or greater - Run the
DashboardEditor
tests - See that failure
I apologize for the breakage here, I did not understand fully how changing ref
behavior would break userland.
To fix this, you need to ensure that Card
forwards refs to the underlying DOM node.
Let me know if this does not work for you, we could consider adding an option to RGL so this breakage is avoided. This will, however, not work in React 17 once ReactDOM.findDOMNode()
is removed.
@jkeen Can you verify that this is still valid?
I tested and the issue is still present. Seems we have a suggested fix that we can implement, thanks @STRML. The fix is small but I think we need to test it carefully so that we don't introduce any regression bugs because of this.
We should probably fix this soon but until then the "workaround" is to not update the react-grid-layout
lib.
We've got a few layers of complication in this one. It'd be relatively simple to add forwardRefs to the cards, but unfortunately, we have our cards wrapped in react-visibility-sensor and react-sizeme--neither of which have been updated to use refs properly and are still relying on findDomNode, so this is blocked until those projects are updated. There is an open PR to update visibility sensor (https://github.com/joshwnj/react-visibility-sensor/pull/161), but nothing for react-sizeme.
We may be able to revisit this one since we have an open PR to remove our dependency on size-me and visibility sensor.