Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing in isOver with empty targetId #1245

Closed
Kadrian opened this issue Mar 7, 2019 · 7 comments
Closed

Crashing in isOver with empty targetId #1245

Kadrian opened this issue Mar 7, 2019 · 7 comments

Comments

@Kadrian
Copy link

Kadrian commented Mar 7, 2019

Describe the bug
I have a connected drop target that is removed from the DOM, once something is dropped on to it.

Now since upgrading to v7.1.0, I'm getting

Uncaught TypeError: Cannot read property '0' of undefined

in the monitor.isOver() call inside the collect function.
Somehow, it sees that the collect function is still called one more time, after the drop target has been removed (targetId is undefined).

Interesting

  • Downgrading back to 6.0.0 resolved the issue.
  • Also, using a short setTimeout wrapper around my callback that removed the drop target, resolved the issue.

Any idea what could cause that?

To Reproduce
Steps to reproduce the behavior:

  1. Connect a Drop target, call monitor.isOver() in collect
  2. in the target, dispatch an action inside drop(...) that removes the drop target
  3. See error

Expected behavior
There is no timing issue with isOver and drop targets can be immediately removed.

Screenshots
bildschirmfoto 2019-03-07 um 00 58 04

Desktop (please complete the following information):

  • OS: os x
  • Browser chrome
  • react-dnd / html5 backend 7.1.0
@RaoHai
Copy link

RaoHai commented Mar 7, 2019

Same issue

@RaoHai
Copy link

RaoHai commented Mar 7, 2019

I tried to revert this change 0feb250#diff-ac418ba19283aec1fb0b70e6570c5613 and resolved.. .

@safonoi
Copy link

safonoi commented Mar 7, 2019

Same issue.
Waiting for fix.
Rolled back to v7.0.2

@cfrank
Copy link

cfrank commented Mar 7, 2019

Confirmed we are receiving the same issue - Reverting to 7.0.2 fixes the issue

@cfrank
Copy link

cfrank commented Mar 7, 2019

This is being caused because the change at 0feb250 is allowing target ID to be undefined but nobody checked the PR with that change for isOverTarget

Currently it's prototype is:

public isOverTarget(targetId: string, options = { shallow: false })

unlike the other functions which changed in that pr which move targetId / sourceId to

targetId: string | undefined
sourceId: string | undefined

and check:

if (!targetId) {
    return false;
}

A fix for this issue will be to check for targetId being undefined here: https://github.com/mattkrick/react-dnd/blob/aafcf7d67f8b3a2035b561e97b7874e1064447e4/packages/dnd-core/src/DragDropMonitorImpl.ts#L128

@darthtrevino
Copy link
Member

This should be fixed by cfrank's PR in a release today

@Kadrian
Copy link
Author

Kadrian commented Mar 8, 2019

Amazing, guys, thanks @cfrank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants