1. log in tohttps://demo.payloadcms.com/admin
2. Navigate to posts
3. Create a new category by clicking on the +
4. Fill out the Name
5. Click Save
6. Click Save
7. Click Save
How do I close the drawer in step 5 on save click?
Duplicates are created with no indication or warning. According to the payload team, it's not a bug, but a feature, which makes some sense. The solution was to set unique to true, preventing duplication.
A sane default should not allow for duplicates; for example, Items are created behind the scene, and it breaks the default duplication feature in the primary collection. It's then necessary to create a hook to override the unique field. Maybe the duplication feature should be disabled by default? Or should the drawer close on save?
Thak you for all your great work; it is much appreciated!
Can I solve this by creating a custom relationship component? My doubt about the custom relationship component is that PayloadCMS changes fast and breaks the custom components.
Can I rely on custom components, or is payload customisation of existing components, not a safe option?
Totally, this makes perfect sense. The current behavior is to keep the drawer open for continued editing but I can see how creating duplicates might be unexpected. Your solution is the correct one, you just need to set
on your category slug and let the API error prevent the update. This didn't work for you? You shouldn't have to create a custom component for this, that would be a nightmare although we're actively overhauling our component library right now. You can track the progress herehttps://github.com/payloadcms/payload/discussions/293
This didn't work for you? no, unique is not an option case it's multi tenant, I could manually prevent a unique check.
Ok in this case you'd just want to write your own validation function to ensure uniqueness within the tenant.
+1 to this, could be addressed with two distinct buttons "Save" and "Save & Close" (my hunch is the latter is the more common use case)
out of curiosity, what is the use case for saving multiple relations without closing the drawer? like add?
The general use case for this is to allow continued editing of the document after save, just like top-level documents. If this has high enough demand, though, the UX here can certainly be revisited. "Save & Close" is as action I could see the need for so it may be worth exploring this further in design.