Skip to content

Payload requires page refresh on BeforeChange hook #9882

Closed

Description

@Sibbern

Describe the Bug

When creating a beforeChange Collection hook and updating fields it updates them on the server side but the client side does not see the update before you do a full page refresh.

Asked in discord community help: https://discord.com/channels/967097582721572934/1315968241658494988

There's been a similiar issue as of version 3.2.2: (#9423) which should have solved in 3.2.2 but it doesn't seem so.

I've tried 3.4, 3.3, 3.2.2 - still the same outcome.

In the repository link that reproduces this issue I've used version 3.5 and it also gives the same outcome.

Link to the code that reproduces this issue

https://github.com/Sibbern/beforechange-hook-bug

Reproduction Steps

  1. Run pnpm i
  2. Run pnpm dev
  3. Go to the browser url: http://localhost:3000/admin and click on the test location (http://localhost:3000/admin/collections/test?limit=10)
  4. Create a new test record and fill out the title, test1 and test2 fields with "something something" and click save. This will update on the client side on creation and it should show "newdata".
  5. Now try and update the same record with new values "something123" and it should update the fields to "newdata" but it does not - only after a page refresh.

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

area: ui

Environment Info

Binaries:
  Node: 20.11.1
  npm: N/A
  Yarn: N/A
  pnpm: 9.7.0
Relevant Packages:
  payload: 3.5.0
  next: 15.0.4
  @payloadcms/db-mongodb: 3.5.0
  @payloadcms/email-nodemailer: 3.5.0
  @payloadcms/graphql: 3.5.0
  @payloadcms/next/utilities: 3.5.0
  @payloadcms/payload-cloud: 3.5.0
  @payloadcms/richtext-lexical: 3.5.0
  @payloadcms/translations: 3.5.0
  @payloadcms/ui/shared: 3.5.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 65350
  Available CPU cores: 32

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Dec 11, 2024
  2. removed
    validate-reproduction
    on Dec 11, 2024
  3. Sibbern commented on Dec 11, 2024

    @Sibbern
    Author

    Similar issue on this: #9691

  4. added a commit that references this issue on Jan 3, 2025
    3ea1d39
  5. removed
    status: needs-triage
    on Jan 3, 2025
  6. github-actions commented on Jan 5, 2025

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  7. locked as resolved and limited conversation to collaborators on Jan 5, 2025
  8. unlocked this conversation on Jan 7, 2025
  9. github-actions commented on Jan 7, 2025

    @github-actions
    Contributor

    🚀 This is included in version v3.15.0

  10. locked and limited conversation to collaborators on Jan 7, 2025
  11. added a commit that references this issue on Feb 21, 2025
    25b66c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions