Skip to content

Commit fcee13b

Browse files
authored
fix: depth field in api view throws error when no value present (#6106)
1 parent 48af782 commit fcee13b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/next/src/views/API/index.client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const APIViewClient: React.FC = () => {
187187
max={10}
188188
min={0}
189189
name="depth"
190-
onChange={(value) => setDepth(value.toString())}
190+
onChange={(value) => setDepth(value?.toString())}
191191
path="depth"
192192
step={1}
193193
/>

test/admin/e2e.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ describe('admin', () => {
312312
await expect(page.locator('#field-sidebarField')).toBeDisabled()
313313
})
314314

315+
test('collection — depth field should have value 0 when empty', async () => {
316+
const { id } = await createPost()
317+
await page.goto(`${postsUrl.edit(id)}/api`)
318+
319+
const depthField = page.locator('#field-depth')
320+
await depthField.fill('')
321+
await expect(depthField).toHaveValue('0')
322+
})
323+
315324
test('global — should not show API tab when disabled in config', async () => {
316325
await page.goto(postsUrl.global(noApiViewGlobalSlug))
317326
await expect(page.locator('.doc-tabs__tabs-container')).not.toContainText('API')

0 commit comments

Comments
 (0)