Skip to content

Commit 28d6377

Browse files
authored
refactor: DH-20098 React 19 support swap react-beautiful-dnd for @hello-pangea/dnd (#2548)
This should be all that is needed for DH-20098 after #2534 This replaces `react-beautiful-dnd` with `@hello-pangea/dnd` which is a fork someone maintained after Atlassian stopped supporting `react-beautiful-dnd`. It fixes the remaining React 18 warnings we see in dev when rendering a `react-beautiful-dnd` list (default props not allowed on functional component). The rollup/aggregations menu should use these components as a test point. I've published an alpha build of this branch and a customer said it was working for them on React 19.
1 parent eaa583e commit 28d6377

22 files changed

Lines changed: 86 additions & 73 deletions

jest.setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Log.setLogLevel(logLevel);
1414

1515
// disable annoying dnd-react warnings
1616
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17-
window['__react-beautiful-dnd-disable-dev-warnings'] = true;
17+
window['__@hello-pangea/dnd-disable-dev-warnings'] = true;
1818

1919
// Define the matchMedia property so we can mock out monaco properly
2020
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom

package-lock.json

Lines changed: 51 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"@types/plotly.js": "^3.0.0",
9696
"@types/pouchdb-browser": "^6.1.3",
9797
"@types/react": "^18.3.12",
98-
"@types/react-beautiful-dnd": "^13.1.2",
9998
"@types/react-dom": "^18.3.1",
10099
"@types/react-is": "^18.3.1",
101100
"@types/react-plotly.js": "^2.6.0",

packages/code-studio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@deephaven/utils": "file:../utils",
4040
"@fortawesome/fontawesome-svg-core": "^6.2.1",
4141
"@fortawesome/react-fontawesome": "^0.2.0",
42+
"@hello-pangea/dnd": "^18.0.1",
4243
"bowser": "^2.11.0",
4344
"classnames": "^2.3.1",
4445
"event-target-shim": "^6.0.2",
@@ -52,7 +53,6 @@
5253
"pouchdb-browser": "^7.2.2",
5354
"pouchdb-find": "^7.2.2",
5455
"react": "^18.3.1",
55-
"react-beautiful-dnd": "^13.1.1",
5656
"react-dom": "^18.3.1",
5757
"react-redux": "^7.2.7",
5858
"react-router-dom": "^5.1.2",

packages/code-studio/src/AppRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function AppRoot(): JSX.Element {
3131
// disable annoying dnd-react warnings
3232
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3333
// @ts-ignore
34-
window['__react-beautiful-dnd-disable-dev-warnings'] = true;
34+
window['__@hello-pangea/dnd-disable-dev-warnings'] = true;
3535
}, []);
3636

3737
return <AppRouter />;

packages/code-studio/src/styleguide/DraggableLists.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type DragStart,
66
type DragUpdate,
77
type DropResult,
8-
} from 'react-beautiful-dnd';
8+
} from '@hello-pangea/dnd';
99
import memoize from 'memoizee';
1010
import {
1111
DragUtils,
@@ -99,7 +99,7 @@ class DraggableLists extends Component<
9999
const isSameList = sourceListIndex === destinationListIndex;
100100
let destinationIndex = destination.index;
101101
if (isSameList && source.index < destination.index) {
102-
// react-beautiful-dnd adjusts the index when dragging within a list already, however that only supports single selection
102+
// @hello-pangea/dnd adjusts the index when dragging within a list already, however that only supports single selection
103103
// We need to change it back to the index we actually want it to drop at before adjusting for the removed source index, as
104104
// we adjust the index based on all the selected ranges, not just the source.index.
105105
destinationIndex += 1;

packages/code-studio/src/styleguide/StyleGuideRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function StyleGuideRoot(): JSX.Element {
2121
// disable annoying dnd-react warnings
2222
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2323
// @ts-ignore
24-
window['__react-beautiful-dnd-disable-dev-warnings'] = true;
24+
window['__@hello-pangea/dnd-disable-dev-warnings'] = true;
2525
}, []);
2626

2727
return (

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@deephaven/utils": "file:../utils",
3232
"@fortawesome/fontawesome-svg-core": "^6.2.1",
3333
"@fortawesome/react-fontawesome": "^0.2.0",
34+
"@hello-pangea/dnd": "^18.0.1",
3435
"@internationalized/date": "^3.5.5",
3536
"@react-spectrum/theme-default": "^3.5.1",
3637
"@react-spectrum/toast": "^3.0.0-beta.16",
@@ -48,7 +49,6 @@
4849
"memoizee": "^0.4.15",
4950
"nanoid": "^5.0.7",
5051
"popper.js": "^1.16.1",
51-
"react-beautiful-dnd": "^13.1.1",
5252
"react-reverse-portal": "^2.3.0",
5353
"react-transition-group": "^4.4.2",
5454
"react-virtualized-auto-sizer": "1.0.7",

packages/components/src/DraggableItemList.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ $draggable-item-grip-color: $mid;
145145
}
146146
}
147147

148-
// Sometimes react-beautiful-dnd still adds the `is-dragging-over` class even though drop is disabled
148+
// Sometimes @hello-pangea/dnd still adds the `is-dragging-over` class even though drop is disabled
149149
// only show the ants if drop isn't disabled
150150
&.is-dragging-over:not(.is-drop-disabled) {
151151
.item-list-scroll-pane {

packages/components/src/DraggableItemList.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Draggable,
66
Droppable,
77
type DraggableChildrenFn,
8-
} from 'react-beautiful-dnd';
8+
} from '@hello-pangea/dnd';
99
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1010
import { vsGripper } from '@deephaven/icons';
1111
import { RangeUtils, type Range } from '@deephaven/utils';
@@ -53,10 +53,10 @@ type DraggableItemListState = {
5353

5454
/**
5555
* Show a draggable item list. It _must_ be used within a `DragDropContext`.
56-
* This implementation uses react-beautiful-dnd for handling dragging and dropping of items.
57-
* We use ItemList to handle selection for multi drag and drop (not built in to react-beautiful-dnd).
58-
* One caveat with the use of react-beautiful-dnd is that it doesn't allow a drag to be initiated while
59-
* using a modifier key: https://github.com/atlassian/react-beautiful-dnd/issues/1678
56+
* This implementation uses @hello-pangea/dnd for handling dragging and dropping of items.
57+
* We use ItemList to handle selection for multi drag and drop (not built in to @hello-pangea/dnd).
58+
* One caveat with the use of @hello-pangea/dnd is that it doesn't allow a drag to be initiated while
59+
* using a modifier key: https://github.com/atlassian/@hello-pangea/dnd/issues/1678
6060
*/
6161
class DraggableItemList<T> extends PureComponent<
6262
DraggableItemListProps<T>,

0 commit comments

Comments
 (0)