clauderic / react-sortable-hoc

A set of higher-order components to turn any list into an animated, accessible and touch-friendly sortable list✌️
https://clauderic.github.io/react-sortable-hoc/
MIT License
10.77k stars 978 forks source link

getScrollingParent's "el instanceof HTMLElement" logic will cause some problems #863

Open karmiy opened 1 year ago

karmiy commented 1 year ago

I have a scenario that causes el instanceof HTMLElement to always return false

If a new window is opened with window.open, mount the component to the child window button using ReactDOM.createPortal react will use the document.createElement of the child window to create these DOM elements

This results in the DOM not being part of the main window, and when I get the DOM elements in my code and execute el instanceof HTMLElement, it always returns false, so I can't get the scroll elements

Here I provide the demo https://stackblitz.com/edit/react-pk98uy?file=src%2FApp.js,src%2Findex.js, which you can click in order: open win -> react create portal -> check element console.log will print false