Skip to content

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

Open
@needsmorecoffee

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions