Skip to content

Commit

Permalink
fix(form-builder): remove BoundaryElementProvider in dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard authored and bjoerge committed Apr 26, 2021
1 parent a0b17e1 commit 8d663a7
Showing 1 changed file with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Marker, Path, SchemaType} from '@sanity/types'
import React, {useMemo, useState} from 'react'
import {BoundaryElementProvider, Box, Dialog, Layer} from '@sanity/ui'
import React, {useMemo} from 'react'
import {Box, Dialog, Layer} from '@sanity/ui'
import {FormFieldPresence, PresenceOverlay} from '@sanity/base/presence'
import {FormBuilderInput} from '../../../../FormBuilderInput'
import {PopoverDialog} from '../../../../transitional/PopoverDialog'
Expand Down Expand Up @@ -50,36 +50,30 @@ export function EditDialog(props: Props) {
presence,
])

const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)

const content = (
<BoundaryElementProvider element={boundaryElement}>
<FormBuilderInput
type={type}
level={0}
value={isEmpty(value) ? undefined : value}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
compareValue={compareValue}
focusPath={focusPath}
readOnly={readOnly || type.readOnly || false}
markers={childMarkers}
path={[{_key: value._key}]}
filterField={filterField}
presence={childPresence}
/>
</BoundaryElementProvider>
<FormBuilderInput
type={type}
level={0}
value={isEmpty(value) ? undefined : value}
onChange={onChange}
onFocus={onFocus}
onBlur={onBlur}
compareValue={compareValue}
focusPath={focusPath}
readOnly={readOnly || type.readOnly || false}
markers={childMarkers}
path={[{_key: value._key}]}
filterField={filterField}
presence={childPresence}
/>
)

if (dialogType === 'fullscreen') {
return (
<Layer>
<Dialog width="auto" id={value._key} onClose={onClose} key={value._key} header={title}>
<PresenceOverlay margins={[0, 0, 1, 0]}>
<Box padding={4} ref={setBoundaryElement}>
{content}
</Box>
<Box padding={4}>{content}</Box>
</PresenceOverlay>
</Dialog>
</Layer>
Expand All @@ -98,19 +92,15 @@ export function EditDialog(props: Props) {
placement="auto"
title={title}
>
<PresenceOverlay margins={[0, 0, 1, 0]}>
<Box ref={setBoundaryElement}>{content}</Box>
</PresenceOverlay>
<PresenceOverlay margins={[0, 0, 1, 0]}>{content}</PresenceOverlay>
</PopoverDialog>
)
}

return (
<Dialog width={1} id={value._key} onClose={onClose} key={value._key} header={title}>
<PresenceOverlay margins={[0, 0, 1, 0]}>
<Box padding={4} ref={setBoundaryElement}>
{content}
</Box>
<Box padding={4}>{content}</Box>
</PresenceOverlay>
</Dialog>
)
Expand Down

0 comments on commit 8d663a7

Please sign in to comment.