Skip to content

Commit

Permalink
fix: recent change could cause Stick to loose its parent host (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil authored Oct 16, 2020
1 parent 2a53705 commit 64d2ca5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/StickPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function StickPortal(
{children}

{top != null && left != null && (
<PortalContext.Provider value={host.parentNode}>
<PortalContext.Provider value={host.parentNode || defaultRoot}>
{createPortal(
<div
ref={containerRef}
Expand All @@ -122,7 +122,11 @@ function StickPortal(
)
}

export const PortalContext = createContext<?Node>(document.body)
invariant(document.body, 'Stick can only be used in a browser environment.')

const defaultRoot = document.body

export const PortalContext = createContext<Node>(defaultRoot)

export default forwardRef<StickPortalPropsT, ?HTMLElement>(StickPortal)

Expand Down

1 comment on commit 64d2ca5

@vercel
Copy link

@vercel vercel bot commented on 64d2ca5 Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.