Skip to content

Commit 8ef00d6

Browse files
dkniffinjquense
authored andcommitted
fix: ie fix for event bindings on unmounted components (jquense#1338)
* IE fix for event bindings on unmounted components. * Fix Unable to get property x of undefined or null reference
1 parent 9689b7d commit 8ef00d6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Selection.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const clickInterval = 250
4444

4545
class Selection {
4646
constructor(node, { global = false, longPressThreshold = 250 } = {}) {
47+
this.isDetached = false
4748
this.container = node
4849
this.globalMouse = !node || global
4950
this.longPressThreshold = longPressThreshold
@@ -95,6 +96,7 @@ class Selection {
9596
}
9697

9798
teardown() {
99+
this.isDetached = true
98100
this.listeners = Object.create(null)
99101
this._onTouchMoveWindowListener && this._onTouchMoveWindowListener.remove()
100102
this._onInitialEventListener && this._onInitialEventListener.remove()
@@ -206,6 +208,10 @@ class Selection {
206208
}
207209

208210
_handleInitialEvent(e) {
211+
if (this.isDetached) {
212+
return
213+
}
214+
209215
const { clientX, clientY, pageX, pageY } = getEventCoordinates(e)
210216
let node = this.container(),
211217
collides,
@@ -344,7 +350,7 @@ class Selection {
344350
}
345351

346352
_handleMoveEvent(e) {
347-
if (this._initialEventData === null) {
353+
if (this._initialEventData === null || this.isDetached) {
348354
return
349355
}
350356

0 commit comments

Comments
 (0)