payload icon indicating copy to clipboard operation
payload copied to clipboard

maxPerDoc set to 0 causes incorrect version count in useDocumentInfo and UI

Open LimChorngUan opened this issue 1 year ago • 0 comments

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

  1. Refer to the reproduction code, enable version and set maxPerDoc to 0 on Post collection
  2. Open dev tool
  3. Open Post collection
  4. Edit a post
  5. Take note of the current version before saving draft
  6. Save draft
  7. Notice versionCount is wrong

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

area: ui, area: core

Environment Info

Payload: 3.5.0

LimChorngUan avatar Dec 11 '24 14:12 LimChorngUan