tajo / react-movable

🔀 Drag and drop for your React lists and tables. Accessible. Tiny.
https://react-movable.pages.dev
MIT License
1.55k stars 51 forks source link

Support for React Portal inside the list #88

Open ivan7237d opened 2 years ago

ivan7237d commented 2 years ago

There is an error that occurs when you're using a React Portal inside a list item, in my case a Modal from react-bootstrap.

When a keyboard event is dispatched inside the portal, it bubbles up the React component tree to react-movable's onKeyDown handler, which calls checkIfInteractive(target: Element, rootElement: Element). But in this case the DOM tree doesn't match the React tree, and because of that target is not a descendant of rootElement. As a result, in the code inside checkIfInteractive, target ends up being null, and an error is thrown at this line: https://github.com/tajo/react-movable/blob/daf3d1f7494903498c3dde450b612596b9be438d/src/utils.ts#L119

cheton commented 9 months ago

It will be great to have an option of including a user-defined checkIfInteractive prop for specific purposes.