github clauderic/dnd-kit @dnd-kit/utilities@3.0.1

latest releases: @dnd-kit/core@6.0.8, @dnd-kit/sortable@7.0.2, @dnd-kit/core@6.0.7...
2 years ago

Patch Changes

  • #509 1c6369e Thanks @clauderic! - Helpers have been updated to support rendering in foreign window contexts (via ReactDOM.render or ReactDOM.createPortal).

    For example, checking if an element is an instance of an HTMLElement is normally done like so:

    if (element instanceof HTMLElement)

    However, when rendering in a different window, this can return false even if the element is indeed an HTMLElement, because this code is equivalent to:

    if (element instanceof window.HTMLElement)

    And in this case, the window of the element is different from the main execution context window, because we are rendering via a portal into another window.

    This can be solved by finding the local window of the element:

    const elementWindow = element.ownerDocument.defaultView;
    
    if (element instanceof elementWindow.HTMLElement)

Don't miss a new dnd-kit release

NewReleases is sending notifications on new releases.