Skip to content

Commit bdfd8df

Browse files
authored
chore(form): remove imports from shouldArrayDialogOpen (#7550)
1 parent 7fcf22a commit bdfd8df

File tree

7 files changed

+5
-181
lines changed

7 files changed

+5
-181
lines changed

packages/sanity/src/core/form/studio/FormBuilder.tsx

+2-13
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ import {
3232
import {DocumentFieldActionsProvider} from './contexts/DocumentFieldActions'
3333
import {FormBuilderInputErrorBoundary} from './FormBuilderInputErrorBoundary'
3434
import {FormProvider} from './FormProvider'
35-
import {
36-
shouldArrayDialogOpen,
37-
TreeEditingDialog,
38-
TreeEditingEnabledProvider,
39-
useTreeEditingEnabled,
40-
} from './tree-editing'
35+
import {TreeEditingDialog, TreeEditingEnabledProvider, useTreeEditingEnabled} from './tree-editing'
4136

4237
/**
4338
* @alpha
@@ -307,15 +302,9 @@ interface RootInputProps {
307302
function RootInput(props: RootInputProps) {
308303
const {rootInputProps, onPathOpen, openPath, renderInput} = props
309304
const treeEditing = useTreeEditingEnabled()
310-
311-
const open = useMemo(
312-
() => shouldArrayDialogOpen(rootInputProps.schemaType, openPath),
313-
[openPath, rootInputProps.schemaType],
314-
)
315-
316305
const isRoot = rootInputProps.id === 'root'
317306

318-
const arrayEditingModal = treeEditing.enabled && isRoot && open && (
307+
const arrayEditingModal = treeEditing.enabled && isRoot && (
319308
<TreeEditingDialog
320309
// eslint-disable-next-line react/jsx-handler-names
321310
onPathFocus={rootInputProps.onPathFocus}

packages/sanity/src/core/form/studio/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export * from './defaults'
33
export * from './FormBuilder'
44
export * from './FormProvider'
55
export * from './inputs'
6-
export {shouldArrayDialogOpen, useTreeEditingEnabled} from './tree-editing'
6+
export {useTreeEditingEnabled} from './tree-editing'
77
export * from './uploads'

packages/sanity/src/core/form/studio/tree-editing/__tests__/shouldArrayDialogOpen.test.ts

-102
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './components'
22
export * from './context'
33
export * from './hooks'
4-
export {shouldArrayDialogOpen} from './utils'
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export * from './build-tree-editing-state'
22
export * from './findArrayTypePaths'
33
export * from './getSchemaField'
4-
export * from './shouldArrayDialogOpen'

packages/sanity/src/core/form/studio/tree-editing/utils/shouldArrayDialogOpen.ts

-49
This file was deleted.

packages/sanity/src/structure/panes/document/statusBar/DocumentStatusBarActions.tsx

+2-14
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
type DocumentActionComponent,
66
type DocumentActionDescription,
77
Hotkeys,
8-
shouldArrayDialogOpen,
9-
useSource,
108
useTimelineSelector,
119
} from 'sanity'
1210

@@ -27,17 +25,9 @@ const DocumentStatusBarActionsInner = memo(function DocumentStatusBarActionsInne
2725
props: DocumentStatusBarActionsInnerProps,
2826
) {
2927
const {disabled, showMenu, states} = props
30-
const {__internal_tasks, schemaType, openPath} = useDocumentPane()
28+
const {__internal_tasks} = useDocumentPane()
3129
const [firstActionState, ...menuActionStates] = states
3230
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(null)
33-
const isTreeArrayEditingEnabled = useSource().beta?.treeArrayEditing?.enabled
34-
35-
// Disable the main document action if the array dialog is open
36-
const isTreeArrayEditingEnabledOpen = useMemo(() => {
37-
if (!isTreeArrayEditingEnabled) return false
38-
39-
return shouldArrayDialogOpen(schemaType, openPath)
40-
}, [isTreeArrayEditingEnabled, openPath, schemaType])
4131

4232
// TODO: This could be refactored to use the tooltip from the button if the firstAction.title was updated to a string.
4333
const tooltipContent = useMemo(() => {
@@ -69,9 +59,7 @@ const DocumentStatusBarActionsInner = memo(function DocumentStatusBarActionsInne
6959
<Stack>
7060
<Button
7161
data-testid={`action-${firstActionState.label}`}
72-
disabled={
73-
disabled || Boolean(firstActionState.disabled) || isTreeArrayEditingEnabledOpen
74-
}
62+
disabled={disabled || Boolean(firstActionState.disabled)}
7563
icon={firstActionState.icon}
7664
// eslint-disable-next-line react/jsx-handler-names
7765
onClick={firstActionState.onHandle}

0 commit comments

Comments
 (0)