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

Default elementFromPoint implementation can result in uncaught exception through normal usage #181

Open
needsmorecoffee opened this issue Oct 2, 2023 · 1 comment

Comments

@needsmorecoffee
Copy link

needsmorecoffee commented Oct 2, 2023

Sometimes the native function document.elementFromPoint(x, y); can return null under normal usage scenarios - e.g. if the element is dragged off-screen - as some browsers (Chrome for mobile is one I encountered issues with) will not return an element if the x, y coords are outside the current viewport.

However, the default elementFromPoint implementation included in the mobile-drag-drop library does not return null if the element returned by the native function is null, instead it returns undefined. This causes issues further down the line as there are null checks but not undefined checks.

Example:

Uncaught TypeError: Cannot read properties of undefined (reading 'getBoundingClientRect')
    at createDragEventFromTouch (drag-utils.ts:113:38)
    at dispatchDragEvent (drag-utils.ts:145:22)
    at DragOperationController._dragAndDropProcessModelIteration (drag-operation-controller.ts:514:21)
    at drag-operation-controller.ts:240:18

This function can be overwritten in the config so it's not a blocker but still might be worth looking at.

@needsmorecoffee
Copy link
Author

needsmorecoffee commented Oct 3, 2023

Clone of #180 apparently does not occur in the latest 2.x branch

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

No branches or pull requests

1 participant