jquense / react-big-calendar

gcal/outlook like calendar component
http://jquense.github.io/react-big-calendar/examples/index.html
MIT License
7.83k stars 2.23k forks source link

IE11 findDOMNode exception in click selection with multiple routes #1234

Closed martin-strobel closed 5 years ago

martin-strobel commented 5 years ago

Do you want to request a feature or report a bug?

Bug

What's the current behavior?

Environment: IE11 with

Test-URL: https://martin-strobel.github.io/rbc-ie11-bug/dashboard Test-Repo: https://github.com/martin-strobel/rbc-ie11-bug/

How to reproduce bug:

  1. Open DEV-Console in IE11
  2. Click on a date
  3. Once weekview is visible: Try to select a timeslot or click somewhere else This also occurs after switching back to dashboard route.
  4. React shows error "Unable to find node on an unmounted component."

image

This seems to happen because of findDOMNode calls, but I was unable to fix this. On an unrelated note: Sometimes timeslots are not rendered correctly, this doesn't seem to influence the reported bug.

This trace happened on the calendar (WeekView) page: image

What's the expected behavior?

There shouldn't be any (uncaught) errors when switching between Routes.

DenysZP commented 5 years ago

It seems that IE incorrectly or not fully unsubscribes from listeners. I suggest adding isDetached flag to the Selection class.

class Selection {
  constructor(node, { global = false, longPressThreshold = 250 } = {}) {
    this.isDetached = false
    ...
  }

  teardown() {
    this.isDetached = true
    ...
  }

  _handleInitialEvent(e) {
    if (this.isDetached) {
      return
    }
    ...
  }
}

If this approach makes sense, I can create a PR.

dkniffin commented 5 years ago

I'm also experiencing this issue, and this change also fixed it for me. @jquense can you confirm that this is a good approach to fixing it, then @DenysZP can make a PR?

dkniffin commented 5 years ago

Additionally, adding another if (this.isDetached) { return } inside _handleMoveEvent addresses this other error that's coming up: Unable to get property 'x' of undefined or null reference

vienpndn commented 5 years ago

I got same issues. Please let me know when will this issue be resolved? @jquense

jquense commented 5 years ago

happy to take this PR if it helps