Fix for the bug where context menus aren't clickable

This commit is contained in:
Aria Minaei 2021-08-05 13:38:51 +02:00
parent ffe8971c55
commit 5d315b8128
2 changed files with 5 additions and 3 deletions

View file

@ -74,8 +74,8 @@ export default function UIRoot() {
<GlobalStyle /> <GlobalStyle />
<ProvideTheme> <ProvideTheme>
<PortalContext.Provider value={portalLayer}> <PortalContext.Provider value={portalLayer}>
<PortalLayer ref={portalLayerRef} />
<Container> <Container>
<PortalLayer ref={portalLayerRef} />
{shouldShowGlobalToolbar && <GlobalToolbar />} {shouldShowGlobalToolbar && <GlobalToolbar />}
{shouldShowTrigger && <TheTrigger />} {shouldShowTrigger && <TheTrigger />}
{shouldShowPanels && <PanelsRoot />} {shouldShowPanels && <PanelsRoot />}

View file

@ -1,13 +1,14 @@
import {pointerEventsAutoInNormalMode} from '@theatre/studio/css' import {pointerEventsAutoInNormalMode} from '@theatre/studio/css'
import getStudio from '@theatre/studio/getStudio'
import useBoundingClientRect from '@theatre/studio/uiComponents/useBoundingClientRect' import useBoundingClientRect from '@theatre/studio/uiComponents/useBoundingClientRect'
import transparentize from 'polished/lib/color/transparentize' import transparentize from 'polished/lib/color/transparentize'
import type {ElementType} from 'react' import type {ElementType} from 'react'
import {useContext} from 'react'
import React, {useLayoutEffect, useState} from 'react' import React, {useLayoutEffect, useState} from 'react'
import {createPortal} from 'react-dom' import {createPortal} from 'react-dom'
import useWindowSize from 'react-use/esm/useWindowSize' import useWindowSize from 'react-use/esm/useWindowSize'
import styled from 'styled-components' import styled from 'styled-components'
import Item, {height as itemHeight} from './Item' import Item, {height as itemHeight} from './Item'
import {PortalContext} from 'reakit'
const minWidth = 190 const minWidth = 190
@ -91,6 +92,7 @@ const RightClickMenu: React.FC<{
window.removeEventListener('mousemove', onMouseMove) window.removeEventListener('mousemove', onMouseMove)
} }
}, [rect, container, props.rightClickPoint, windowSize, props.onRequestClose]) }, [rect, container, props.rightClickPoint, windowSize, props.onRequestClose])
const portalLayer = useContext(PortalContext)
const items = Array.isArray(props.items) ? props.items : props.items() const items = Array.isArray(props.items) ? props.items : props.items()
@ -109,7 +111,7 @@ const RightClickMenu: React.FC<{
/> />
))} ))}
</Container>, </Container>,
getStudio()!.ui.containerShadow, portalLayer!,
) )
} }