Skip to content

Commit 9894c6d

Browse files
authored
chore(core): end "Array Tree Editing" beta (#7411)
* chore(core): end "Array Tree Editing" beta * chore(tests): skip tree editing tests * chore(types): deprecate treeEditing option in arrays * fix(tests): revert array tests to before tree editing dialog
1 parent dc40f6e commit 9894c6d

File tree

11 files changed

+26
-49
lines changed

11 files changed

+26
-49
lines changed

packages/@sanity/types/src/schema/definition/type/array.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface ArrayOptions<V = unknown> extends SearchConfiguration {
2727
/**
2828
* A boolean flag to enable or disable tree editing for the array.
2929
* If there are any nested arrays, they will inherit this value.
30+
* @deprecated tree editing beta feature has been disabled
3031
*/
3132
treeEditing?: boolean
3233
}

packages/sanity/playwright-ct/tests/formBuilder/tree-editing/TreeEditing.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const DOCUMENT_VALUE: SanityDocument = {
8686
],
8787
}
8888

89-
test.describe('Tree editing', () => {
89+
test.skip('Tree editing', () => {
9090
test('should open tree editing dialog when adding an item and close it when clicking done', async ({
9191
mount,
9292
page,

packages/sanity/playwright-ct/tests/formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const DOCUMENT_VALUE: SanityDocument = {
5353
],
5454
}
5555

56-
test.describe('Tree Editing with nested objects', () => {
56+
test.skip('Tree Editing with nested objects', () => {
5757
test('should navigate and display nested objects correctly', async ({mount, page}) => {
5858
// Mount the TreeEditingStory component with initial open path
5959
await mount(

packages/sanity/src/core/config/configPropertyReducers.ts

-23
Original file line numberDiff line numberDiff line change
@@ -310,29 +310,6 @@ export const documentCommentsEnabledReducer = (opts: {
310310
return result
311311
}
312312

313-
export const arrayEditingReducer = (opts: {
314-
config: PluginOptions
315-
initialValue: boolean
316-
}): boolean => {
317-
const {config, initialValue} = opts
318-
const flattenedConfig = flattenConfig(config, [])
319-
320-
const result = flattenedConfig.reduce((acc, {config: innerConfig}) => {
321-
const resolver = innerConfig.beta?.treeArrayEditing?.enabled
322-
323-
if (!resolver && typeof resolver !== 'boolean') return acc
324-
if (typeof resolver === 'boolean') return resolver
325-
326-
throw new Error(
327-
`Expected \`beta.treeArrayEditing.enabled\` to be a boolean, but received ${getPrintableType(
328-
resolver,
329-
)}`,
330-
)
331-
}, initialValue)
332-
333-
return result
334-
}
335-
336313
export const internalTasksReducer = (opts: {
337314
config: PluginOptions
338315
}): {footerAction: ReactNode} | undefined => {

packages/sanity/src/core/config/prepareConfig.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {operatorDefinitions} from '../studio/components/navbar/search/definition
1919
import {type InitialValueTemplateItem, type Template, type TemplateItem} from '../templates'
2020
import {EMPTY_ARRAY, isNonNullable} from '../util'
2121
import {
22-
arrayEditingReducer,
2322
documentActionsReducer,
2423
documentBadgesReducer,
2524
documentCommentsEnabledReducer,
@@ -629,7 +628,8 @@ function resolveSource({
629628
},
630629
beta: {
631630
treeArrayEditing: {
632-
enabled: arrayEditingReducer({config, initialValue: false}),
631+
// This beta feature is no longer available.
632+
enabled: false,
633633
},
634634
},
635635
}

packages/sanity/src/core/config/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -901,10 +901,11 @@ interface BetaFeatures {
901901
/**
902902
* @beta
903903
* @hidden
904+
* @deprecated beta feature is no longer available.
904905
* */
905906
treeArrayEditing?: {
906907
/**
907-
* Enables the tree array editing feature.
908+
* @deprecated beta feature is no longer available.
908909
*/
909910
enabled: boolean
910911
}

packages/sanity/src/core/form/studio/tree-editing/__tests__/useTreeEditingEnabled.test.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('useTreeEditingEnabled', () => {
4040
expect(result.current).toEqual({enabled: false, legacyEditing: false})
4141
})
4242

43-
test('should return enabled: true when config is enabled', () => {
43+
test('should return enabled: false when config is enabled, beta feature is no longer available', () => {
4444
const features = {
4545
beta: {
4646
treeArrayEditing: {
@@ -52,18 +52,18 @@ describe('useTreeEditingEnabled', () => {
5252

5353
const {result} = renderHook(() => useTreeEditingEnabled(), {wrapper})
5454

55-
expect(result.current).toEqual({enabled: true, legacyEditing: false})
55+
expect(result.current).toEqual({enabled: false, legacyEditing: false})
5656
})
5757

5858
test('should return legacyEditing: true when legacyEditing is true', () => {
5959
const {result} = renderHook(() => useTreeEditingEnabled(), {wrapper: legacyEditingWrapper})
6060

61-
expect(result.current).toEqual({enabled: true, legacyEditing: true})
61+
expect(result.current).toEqual({enabled: false, legacyEditing: true})
6262
})
6363

6464
test('should return legacyEditing: true when parent has legacyEditing enabled', () => {
6565
const {result} = renderHook(() => useTreeEditingEnabled(), {wrapper: nestedWrapper})
6666

67-
expect(result.current).toEqual({enabled: true, legacyEditing: true})
67+
expect(result.current).toEqual({enabled: false, legacyEditing: true})
6868
})
6969
})

packages/sanity/src/core/form/studio/tree-editing/context/enabled/TreeEditingEnabledProvider.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {useMemo} from 'react'
22
import {TreeEditingEnabledContext} from 'sanity/_singletons'
33

4-
import {useSource} from '../../../../../studio/source'
54
import {type TreeEditingEnabledContextValue, useTreeEditingEnabled} from './useTreeEditingEnabled'
65

76
interface TreeEditingEnabledProviderProps {
@@ -11,8 +10,6 @@ interface TreeEditingEnabledProviderProps {
1110

1211
export function TreeEditingEnabledProvider(props: TreeEditingEnabledProviderProps): JSX.Element {
1312
const {children, legacyEditing: legacyEditingProp} = props
14-
15-
const {beta} = useSource()
1613
const parentContextValue = useTreeEditingEnabled()
1714

1815
const value = useMemo((): TreeEditingEnabledContextValue => {
@@ -26,10 +23,10 @@ export function TreeEditingEnabledProvider(props: TreeEditingEnabledProviderProp
2623
legacyEditingProp
2724

2825
return {
29-
enabled: beta?.treeArrayEditing?.enabled === true,
26+
enabled: false, // The tree editing beta feature has been disabled
3027
legacyEditing: Boolean(legacyEditing),
3128
}
32-
}, [beta?.treeArrayEditing?.enabled, legacyEditingProp, parentContextValue.legacyEditing])
29+
}, [legacyEditingProp, parentContextValue.legacyEditing])
3330

3431
return (
3532
<TreeEditingEnabledContext.Provider value={value}>

test/e2e/tests/inputs/array.spec.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ test(`file drop event should not propagate to dialog parent`, async ({
4242

4343
// Open the dialog.
4444
await page.getByRole('button', {name: fileName}).click()
45-
await expect(page.locator('#tree-editing-dialog')).toBeVisible()
45+
await expect(page.getByRole('dialog')).toBeVisible()
4646

4747
// Drop the file again; this time, while the dialog is open.
4848
//
4949
// - The drop event should not propagate to the parent.
5050
// - Therefore, the drop event should not cause the image to be added to the list again.
51-
await page.locator('#tree-editing-dialog').dispatchEvent('drop', {dataTransfer})
51+
await page.getByRole('dialog').dispatchEvent('drop', {dataTransfer})
5252

5353
// Close the dialog.
54-
await page.getByTestId('tree-editing-done').click()
55-
await expect(await page.locator('#tree-editing-dialog')).not.toBeVisible()
54+
await page.keyboard.press('Escape')
55+
await expect(page.getByRole('dialog')).not.toBeVisible()
5656

5757
// Ensure the list still contains one item.
5858
expect(item).toHaveCount(1)
@@ -93,8 +93,9 @@ test(`Scenario: Adding a new type from multiple options`, async ({page, createDr
9393
await expect(titleInput).toHaveValue('Book title')
9494

9595
// And the dialog is closed
96-
await page.keyboard.press('Escape')
97-
await expect(await insertDialog).not.toBeVisible()
96+
const closeDialogButton = insertDialog.getByLabel('Close dialog')
97+
await closeDialogButton.click()
98+
await expect(insertDialog).not.toBeVisible()
9899

99100
// Then a new item is inserted in the array
100101
const bookItem = field.getByText('Book title')
@@ -217,9 +218,9 @@ function createArrayFieldLocators(page: Page) {
217218
const popover = page.getByTestId('document-panel-portal')
218219
const popoverMenu = popover.getByRole('menu')
219220
const popoverMenuItem = (name: string) => popoverMenu.getByRole('menuitem', {name})
220-
const insertDialog = page.locator('#tree-editing-dialog')
221+
const insertDialog = page.getByRole('dialog')
221222
const input = (label: string) => insertDialog.getByLabel(label)
222-
const closeDialogButton = page.getByTestId('tree-editing-done')
223+
const closeDialogButton = insertDialog.getByLabel('Close dialog')
223224

224225
return {
225226
items,

test/e2e/tests/tree-editing/TreeEditingBasicInteraction.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {expect} from '@playwright/test'
22
import {test} from '@sanity/test'
33

4-
test.describe('basic - open and close', () => {
4+
test.skip('basic - open and close', () => {
55
test.beforeEach(async ({page, createDraftDocument}) => {
66
// wait for form to be attached
77
await createDraftDocument('/test/content/input-debug;objectsDebug')
@@ -40,7 +40,7 @@ test.describe('basic - open and close', () => {
4040
})
4141
})
4242

43-
test.describe('basic - main document action', () => {
43+
test.skip('basic - main document action', () => {
4444
test.beforeEach(async ({page, createDraftDocument}) => {
4545
// wait for form to be attached
4646
await createDraftDocument('/test/content/input-debug;objectsDebug')

test/e2e/tests/tree-editing/TreeEditingNavigation.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {expect} from '@playwright/test'
22
import {test} from '@sanity/test'
33

4-
test.describe('navigation - tree sidebar', () => {
4+
test.skip('navigation - tree sidebar', () => {
55
test.beforeEach(async ({page, createDraftDocument, browserName}) => {
66
// set up an array with two items: Albert, the whale and Lucy, the cat
77

@@ -118,7 +118,7 @@ test.describe('navigation - tree sidebar', () => {
118118
})
119119
})
120120

121-
test.describe('navigation - breadcrumb', () => {
121+
test.skip('navigation - breadcrumb', () => {
122122
test.beforeEach(async ({page, createDraftDocument}) => {
123123
// set up an array with two items: Albert, the whale and Lucy, the cat
124124
await createDraftDocument('/test/content/input-debug;objectsDebug')

0 commit comments

Comments
 (0)