Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): place top portal at higher z index than page level portal #6950

Merged
merged 2 commits into from
Nov 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions app/src/components/portal/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import * as React from 'react'
import ReactDom from 'react-dom'
import { Box } from '@opentrons/components'

type PortalLevel = 'page' | 'top'

Expand All @@ -13,20 +14,25 @@ type State = {|
hasRoot: boolean,
|}

const PORTAL_ROOT_ID_BY_LEVEL: { [PortalLevel]: string } = {
page: '__otAppModalPortalRoot',
top: '__otAppTopPortalRoot',
type PortalLevelInfo = {|
id: string,
zIndex: number | string,
|}

const PORTAL_ROOT_PROPS_BY_LEVEL: { [PortalLevel]: PortalLevelInfo } = {
page: { id: '__otAppModalPortalRoot', zIndex: 1 },
top: { id: '__otAppTopPortalRoot', zIndex: 10 },
}

const getPortalRoot = level =>
global.document.getElementById(PORTAL_ROOT_ID_BY_LEVEL[level])
global.document.getElementById(PORTAL_ROOT_PROPS_BY_LEVEL[level].id)

export function PortalRoot(): React.Node {
return <div id={PORTAL_ROOT_ID_BY_LEVEL.page} />
return <Box {...PORTAL_ROOT_PROPS_BY_LEVEL.page} />
}

export function TopPortalRoot(): React.Node {
return <div id={PORTAL_ROOT_ID_BY_LEVEL.top} />
return <Box {...PORTAL_ROOT_PROPS_BY_LEVEL.top} />
}

// the children of Portal are rendered into the PortalRoot if it exists in DOM
Expand Down