From 1f547234b55a128687c9aebdfb7391c2d751ae1b Mon Sep 17 00:00:00 2001 From: Daniel Cousens <413395+dcousens@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:14:25 +1100 Subject: [PATCH] Fix ui.inlineCreate for relationships submitting the parent form --- .changeset/fix-inline-create.md | 5 +++++ .../types/relationship/views/cards/InlineCreate.tsx | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 .changeset/fix-inline-create.md diff --git a/.changeset/fix-inline-create.md b/.changeset/fix-inline-create.md new file mode 100644 index 00000000000..c227405d885 --- /dev/null +++ b/.changeset/fix-inline-create.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/core': patch +--- + +Fix ui.inlineCreate: { ... } for relationships submitting the parent form of nested relationship fields diff --git a/packages/core/src/fields/types/relationship/views/cards/InlineCreate.tsx b/packages/core/src/fields/types/relationship/views/cards/InlineCreate.tsx index 371cc90c567..c38a889a23e 100644 --- a/packages/core/src/fields/types/relationship/views/cards/InlineCreate.tsx +++ b/packages/core/src/fields/types/relationship/views/cards/InlineCreate.tsx @@ -1,7 +1,7 @@ /** @jsxRuntime classic */ /** @jsx jsx */ -import { type FormEvent, useState } from 'react' +import { useState } from 'react' import { jsx, Stack } from '@keystone-ui/core' import isDeepEqual from 'fast-deep-equal' import { useToasts } from '@keystone-ui/toast' @@ -53,11 +53,9 @@ export function InlineCreate ({ }) const invalidFields = useInvalidFields(fields, value) - const [forceValidation, setForceValidation] = useState(false) - const onSubmit = (event: FormEvent) => { - event.preventDefault() + const onSubmit = () => { const newForceValidation = invalidFields.size !== 0 setForceValidation(newForceValidation) @@ -106,7 +104,7 @@ export function InlineCreate ({ } return ( -
+
{error && ( @@ -119,7 +117,7 @@ export function InlineCreate ({ value={value} /> - - +
) }