Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
add patch for react-dnd/react-dnd#3565
Browse files Browse the repository at this point in the history
  • Loading branch information
jtbandes committed May 22, 2023
1 parent 7339359 commit 6ef611d
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"resolutions": {
"@types/node": "15.3.0",
"react-dom": "patch:react-dom@npm:17.0.2#./patches/react-dom.patch",
"react-use": "patch:react-use@17.4.0#./patches/react-use.patch"
"react-use": "patch:react-use@17.4.0#./patches/react-use.patch",
"react-dnd": "patch:react-dnd@npm:16.0.1#./patches/react-dnd.patch"
},
"devDependencies": {
"@actions/core": "1.10.0",
Expand Down
123 changes: 123 additions & 0 deletions patches/react-dnd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
diff --git a/dist/internals/SourceConnector.js b/dist/internals/SourceConnector.js
index f8332d6ec9ef88aa74d8a04d055461377fdb2047..376771caa79a1d505a190c9127a657248a225085 100644
--- a/dist/internals/SourceConnector.js
+++ b/dist/internals/SourceConnector.js
@@ -42,11 +42,12 @@ export class SourceConnector {
this.lastConnectedDragSource = dragSource;
return didChange;
}
- if (didChange) {
+ if (didChange || !this.isDragSourceConnected) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDragSource = dragSource;
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
+ this.isDragSourceConnected = true;
}
return didChange;
}
@@ -64,11 +65,12 @@ export class SourceConnector {
this.lastConnectedDragPreview = dragPreview;
return;
}
- if (didChange) {
+ if (didChange || !this.isDragPreviewConnected) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDragPreview = dragPreview;
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
+ this.isDragPreviewConnected = true;
}
}
didHandlerIdChange() {
@@ -91,14 +93,14 @@ export class SourceConnector {
this.dragSourceUnsubscribe();
this.dragSourceUnsubscribe = undefined;
}
+ this.isDragSourceConnected = false;
}
disconnectDragPreview() {
if (this.dragPreviewUnsubscribe) {
this.dragPreviewUnsubscribe();
this.dragPreviewUnsubscribe = undefined;
- this.dragPreviewNode = null;
- this.dragPreviewRef = null;
}
+ this.isDragPreviewConnected = false;
}
get dragSource() {
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
@@ -144,6 +146,8 @@ export class SourceConnector {
// The drag preview may either be attached via ref or connect function
this.dragPreviewRef = null;
this.dragPreviewOptionsInternal = null;
+ this.isDragSourceConnected = false;
+ this.isDragPreviewConnected = false;
this.lastConnectedHandlerId = null;
this.lastConnectedDragSource = null;
this.lastConnectedDragSourceOptions = null;
diff --git a/src/internals/SourceConnector.ts b/src/internals/SourceConnector.ts
index 7ac4ced60f5248295b3099ded72696b4b79459b7..a87ff5733ebdf1cfeb6adc80e90725bdabdf883b 100644
--- a/src/internals/SourceConnector.ts
+++ b/src/internals/SourceConnector.ts
@@ -53,6 +53,8 @@ export class SourceConnector implements Connector {
private dragPreviewOptionsInternal: DragPreviewOptions | null = null
private dragPreviewUnsubscribe: Unsubscribe | undefined

+ private isDragSourceConnected = false
+ private isDragPreviewConnected = false
private lastConnectedHandlerId: Identifier | null = null
private lastConnectedDragSource: any = null
private lastConnectedDragSourceOptions: any = null
@@ -118,7 +120,7 @@ export class SourceConnector implements Connector {
return didChange
}

- if (didChange) {
+ if (didChange || !this.isDragSourceConnected) {
this.lastConnectedHandlerId = this.handlerId
this.lastConnectedDragSource = dragSource
this.lastConnectedDragSourceOptions = this.dragSourceOptions
@@ -127,6 +129,7 @@ export class SourceConnector implements Connector {
dragSource,
this.dragSourceOptions,
)
+ this.isDragSourceConnected = true
}
return didChange
}
@@ -152,7 +155,7 @@ export class SourceConnector implements Connector {
return
}

- if (didChange) {
+ if (didChange || !this.isDragPreviewConnected) {
this.lastConnectedHandlerId = this.handlerId
this.lastConnectedDragPreview = dragPreview
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions
@@ -161,6 +164,7 @@ export class SourceConnector implements Connector {
dragPreview,
this.dragPreviewOptions,
)
+ this.isDragPreviewConnected = true
}
}

@@ -195,15 +199,15 @@ export class SourceConnector implements Connector {
this.dragSourceUnsubscribe()
this.dragSourceUnsubscribe = undefined
}
+ this.isDragSourceConnected = false
}

public disconnectDragPreview() {
if (this.dragPreviewUnsubscribe) {
this.dragPreviewUnsubscribe()
this.dragPreviewUnsubscribe = undefined
- this.dragPreviewNode = null
- this.dragPreviewRef = null
}
+ this.isDragPreviewConnected = false
}

private get dragSource() {
27 changes: 26 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17442,7 +17442,7 @@ __metadata:
languageName: node
linkType: hard

"react-dnd@npm:16.0.1, react-dnd@npm:^16.0.1":
"react-dnd@npm:16.0.1":
version: 16.0.1
resolution: "react-dnd@npm:16.0.1"
dependencies:
Expand All @@ -17467,6 +17467,31 @@ __metadata:
languageName: node
linkType: hard

"react-dnd@patch:react-dnd@npm:16.0.1#./patches/react-dnd.patch::locator=foxglove-studio%40workspace%3A.":
version: 16.0.1
resolution: "react-dnd@patch:react-dnd@npm%3A16.0.1#./patches/react-dnd.patch::version=16.0.1&hash=7ebec9&locator=foxglove-studio%40workspace%3A."
dependencies:
"@react-dnd/invariant": ^4.0.1
"@react-dnd/shallowequal": ^4.0.1
dnd-core: ^16.0.1
fast-deep-equal: ^3.1.3
hoist-non-react-statics: ^3.3.2
peerDependencies:
"@types/hoist-non-react-statics": ">= 3.3.1"
"@types/node": ">= 12"
"@types/react": ">= 16"
react: ">= 16.14"
peerDependenciesMeta:
"@types/hoist-non-react-statics":
optional: true
"@types/node":
optional: true
"@types/react":
optional: true
checksum: 86af5aefd56b6c88e3977d3580266152d53f959413297ae2800c9b9599aa7d372bff2873a88b8c72deb03859fe2dbe283098a73b0135220c94bd4959f56a90a1
languageName: node
linkType: hard

"react-docgen-typescript@npm:^2.2.2":
version: 2.2.2
resolution: "react-docgen-typescript@npm:2.2.2"
Expand Down

0 comments on commit 6ef611d

Please sign in to comment.