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

Save button not correctly disabled when there's no changes #9000

Open
shangjieJayZhou opened this issue Nov 3, 2024 · 1 comment · May be fixed by #9025
Open

Save button not correctly disabled when there's no changes #9000

shangjieJayZhou opened this issue Nov 3, 2024 · 1 comment · May be fixed by #9025
Assignees
Labels

Comments

@shangjieJayZhou
Copy link

Describe the Bug

When editing a collection, the "Save" button should be disabled upon no changes to this collection.

However, in my case, I have Block Item Block inside collection Courses and the block has a "type: 'relationship'" to another collection Items, when collection Items is edited directly inside Courses, the "Save" button on the Courses editing page becomes clickable and throws error "This relationship field has the following invalid relationships: [object Object] 0" upon clicking.

Image
This bug was introduced after upgrading from beta.103 to beta.104.

Link to the code that reproduces this issue

https://github.com/shangjieJayZhou/payload3.0-bug-report

Reproduction Steps

  1. run "pnpm i"

  2. copy everything in ".env.local.example" into a file ".env"

  3. Either tweak the DATABASE_URI in .env to fit your local db, or make sure you have a locally running postgres db on 5432 with database "lms" and schema "payload-content"

  4. run "pnpm dev"

  5. (assume your payload is running on 3000) Log in to http://localhost:3000/admin

  6. Go to collection Courses

  7. Click "Create New" and you should be seeing this
    Image

  8. Click "Add Content" and add an Item Block, and you should be seeing this
    Image

  9. Click the "+" button on the right to add an item inside this newly created Item Block. Give it any name and price, should look something like this
    Image

  10. Click "Save" to add this item and close this item window, you should be back to the Course page and see this
    Image

  11. Click "Save" on the top right to save changes to this Course, after clicking "Save" there should be no error and you should see that the "Save" button now turns grey:
    Image

  12. Go edit the item you just added by clicking on the edit icon on the item inside the Item Block, then change the name(or the price, doesn't matter) to something different and save, after saving you should see something like this:
    Image

  13. Close the item window and you should be back to the course editing page, and you should see that the "Save" button is no longer greyed out and is clickable (while it SHOULD NOT be)
    Image

  14. Click on "Save" and you should see an error, like this
    Image

Which area(s) are affected? (Select all that apply)

area: ui, plugin: nested-docs

Environment Info

Binaries:
Node: 20.13.1
npm: 10.5.2
Yarn: 1.22.22
pnpm: 9.7.0
Relevant Packages:
payload: 3.0.0-beta.123
next: 15.0.0
@payloadcms/db-mongodb: 3.0.0-beta.123
@payloadcms/db-postgres: 3.0.0-beta.123
@payloadcms/graphql: 3.0.0-beta.123
@payloadcms/next/utilities: 3.0.0-beta.123
@payloadcms/richtext-lexical: 3.0.0-beta.123
@payloadcms/richtext-slate: 3.0.0-beta.123
@payloadcms/translations: 3.0.0-beta.123
@payloadcms/ui/shared: 3.0.0-beta.123
react: 19.0.0-rc-65a56d0e-20241020
react-dom: 19.0.0-rc-65a56d0e-20241020
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.5.0: Wed May 1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112
Available memory (MB): 16384
Available CPU cores: 8

@shangjieJayZhou shangjieJayZhou added status: needs-triage Possible bug which hasn't been reproduced yet v3 validate-reproduction labels Nov 3, 2024
@thgh
Copy link
Contributor

thgh commented Nov 4, 2024

Encountered the same bug (at least since v117)

  1. Open document that has relationship
  2. Click the edit icon of the relation
  3. Make a change and click save
  4. Close the modal
  5. The save button lights up, clicking it shows this error:
    This relationship field has the following invalid relationships: [object Object] 0

It seems that the relation modal passes down the complete object on save instead of just the id

@JessChowdhury JessChowdhury self-assigned this Nov 4, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants