Number id and versions produce incorrect result for collection list
Link to reproduction
https://github.com/GeorgeHulpoi/payload-number-id-versions-bug
Describe the Bug
When using a number ID, in the collection list, appears also the versions:
To Reproduce
- Create a post (id: 1, title: "Title")
- Edit that post (title: "Title Edited")
Now you will see 2 posts in collection list.
Payload Version
2.9.0
Adapters and Plugins
MongoDB
Can confirm, this makes versions unusable in production for custom IDs. I will have a look to see if there is a fix.
Looked at the source code, it is like this by design, it is not a bug. However, it happens only when you have drafts on, not just plain versions. It also happens to all other collections, not just Custom ID ones.
You can overcome this by using a filter (e.g. status = "published") but this is not ideal and the UX is not great. Imagine a team of editors working on thousands (or hundreds of thousands) of pieces of content.
Kinda weird situation to solve as when creating a new item, if you don't publish it, then you would not be able to find it anymore if we don't display drafts in the collection view. A solution would be to only display drafts when there is no published version.
I guess some people find the current design ok, as it is probably fine for small content sites, but what if we had a feature where we could specify via the collection config how drafts are handled?
drafts: {
show: 'all', // default
show: 'latest', // only show latest draft
hideIfPublished: true // do not show drafts if there is a published version
}
This issue was automatically closed due to lack of activity. If this issue is still relevant against the latest codebase, please create a new issue.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.