maxPerDoc set to 0 causes incorrect version count in useDocumentInfo and UI
Describe the Bug
According to the versioning configuration documentation, setting maxPerDoc to 0 should allow unlimited versions to be saved. However, there is an issue with how the version count is handled in the client-side code.
In this line of code, useDocumentInfo incorrectly returns 0 upon saving a draft. This also leads to an UI issue, in the "Versions" tab, no version count is displayed after saving a draft. https://github.com/user-attachments/assets/3b6c0cac-ffa6-4695-8b32-69edeb86f414
The issue is limited to the client side; if the page is refreshed or you navigate to another tab and back, the correct version count is displayed.
Link to the code that reproduces this issue
https://github.com/LimChorngUan/payload-bug-reproduction/commit/ef9521039021875a6982bb5038fb1ca0b9c53390
Reproduction Steps
- Refer to the reproduction code, enable version and set
maxPerDocto0on Post collection - Open dev tool
- Open Post collection
- Edit a post
- Take note of the current version before saving draft
- Save draft
- Notice
versionCountis wrong
Which area(s) are affected? (Select all that apply)
area: ui, area: core
Environment Info
Payload: 3.5.0