Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent inline related item form from submitting the parent form #8123

Merged
merged 5 commits into from
Nov 28, 2022

Conversation

januzis
Copy link
Contributor

@januzis januzis commented Nov 24, 2022

Inline related item creation is currently semi-broken, because the related item form in a drawer is submitting the main form as well. This results either in the main form showing validation errors just after the related item is created, or, if all the fields in the main form were filled correctly, in the main form being submitted automatically without any value in the relation field.

I think the #7594 introduced the regression, when a separate page started being used to create new items, instead of using the drawer component.

Steps to reproduce the problem (using tests/test-projects/basic):

  1. Go to the new task page (http://localhost:3000/tasks/create);
  2. Fill in the "Label" field to make the main form valid (it's the only required field);
  3. Click "Create related Person" button to open the person form in a drawer;
  4. Fill in any name and click "Create Person" to submit the form;
  5. You should see that the Task form has been submitted as well, and the value of the "Assigned To" field isn't set.

I've created a test following these steps, which fails in the current main branch, and passes with my fix. The fix itself is very simple - stop form submit event propagation in the drawer component.

@changeset-bot
Copy link

changeset-bot bot commented Nov 24, 2022

🦋 Changeset detected

Latest commit: 1b6c49c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@keystone-ui/modals Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Nov 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
keystone-next-docs ✅ Ready (Inspect) Visit Preview Nov 27, 2022 at 11:12PM (UTC)

@vercel vercel bot temporarily deployed to Preview November 24, 2022 21:49 Inactive
@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 24, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1b6c49c:

Sandbox Source
@keystone-6/sandbox Configuration

@vercel vercel bot temporarily deployed to Preview November 24, 2022 21:56 Inactive
@januzis januzis marked this pull request as ready for review November 24, 2022 22:12
@vercel vercel bot temporarily deployed to Preview November 25, 2022 00:10 Inactive
Copy link
Member

@dcousens dcousens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me

@vercel vercel bot temporarily deployed to Preview November 27, 2022 23:12 Inactive
@emmatown emmatown merged commit cf18ee7 into keystonejs:main Nov 28, 2022
@januzis januzis deleted the inline-create-fix branch November 28, 2022 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants