diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx index 9672097713a9b..c3960349e5cd0 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx @@ -31,6 +31,24 @@ DragEffects.displayName = 'DragEffects'; export const DraggablePortalContext = createContext(false); export const useDraggablePortalContext = () => useContext(DraggablePortalContext); +/** + * Wraps the `react-beautiful-dnd` error boundary. See also: + * https://github.com/atlassian/react-beautiful-dnd/blob/v12.0.0/docs/guides/setup-problem-detection-and-error-recovery.md + * + * NOTE: This extends from `PureComponent` because, at the time of this + * writing, there's no hook equivalent for `componentDidCatch`, per + * https://reactjs.org/docs/hooks-faq.html#do-hooks-cover-all-use-cases-for-classes + */ +class DragDropErrorBoundary extends React.PureComponent { + componentDidCatch() { + this.forceUpdate(); // required for recovery + } + + render() { + return this.props.children; + } +} + const Wrapper = styled.div` display: inline-block; max-width: 100%; @@ -88,45 +106,47 @@ const DraggableWrapperComponent = React.memo( return ( - - {droppableProvided => ( -
- - {(provided, snapshot) => ( - - - {truncate && !snapshot.isDragging ? ( - - {render(dataProvider, provided, snapshot)} - - ) : ( - - {render(dataProvider, provided, snapshot)} - - )} - - - )} - - {droppableProvided.placeholder} -
- )} -
+ + + {droppableProvided => ( +
+ + {(provided, snapshot) => ( + + + {truncate && !snapshot.isDragging ? ( + + {render(dataProvider, provided, snapshot)} + + ) : ( + + {render(dataProvider, provided, snapshot)} + + )} + + + )} + + {droppableProvided.placeholder} +
+ )} +
+
); },