This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add patch for react-dnd/react-dnd#3565
- Loading branch information
Showing
3 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters