Skip to content

beforeValidate hook runs, but doesn't update UI during update operation #9423

Closed

Description

@yulolimum

Describe the Bug

Hello, this originally was observed with the example app's "slug" field. However this was reproduced on a fresh payload app.

Setting up a beforeValidate hook to transform a field value works on both create and update. But...

During create the transformation is immediately available in the UI. I suspect due to the page path going from /create -> /{resource_id}

During update the transformation runs, butis not reflected in the UI.

Here is a video demoing the issue:

  • In the first part, you will see the field changes correctly during create.
  • In the second part (update), you will see the field will only change after a page refresh.
yulolimum-capture-2024-11-21--18-43-36.mp4

Link to the code that reproduces this issue

https://github.com/yulolimum/tmp-payload-before-validate-repro

Reproduction Steps

  1. Clone Repo

    git clone [email protected]:yulolimum/tmp-payload-before-validate-repro.git
  2. Install Deps

    cd tmp-payload-before-validate-repro
    yarn
  3. Start Dev Server

    yarn dev
  4. Login

  5. Create a New User

    • After filling out the field "Demo Field" with any text and clicking "Save", the field should change to "you should see this".
  6. Update the User

    • Change the "Demo Field" to any text and click "Save". Observe - field remains with the same text you typed.
  7. Refresh the Page

    • After refreshing the page, the field should change to "you should see this".

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

area: core

Environment Info

Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: 4.5.2
  pnpm: N/A
Relevant Packages:
  payload: 3.0.2
  next: 15.0.3
  @payloadcms/db-mongodb: 3.0.2
  @payloadcms/email-nodemailer: 3.0.2
  @payloadcms/graphql: 3.0.2
  @payloadcms/next/utilities: 3.0.2
  @payloadcms/plugin-seo: 3.0.2
  @payloadcms/richtext-lexical: 3.0.2
  @payloadcms/translations: 3.0.2
  @payloadcms/ui/shared: 3.0.2
  react: 19.0.0-rc-65a56d0e-20241020
  react-dom: 19.0.0-rc-65a56d0e-20241020
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000
  Available memory (MB): 65536
  Available CPU cores: 10

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Nov 22, 2024
  2. removed
    validate-reproduction
    on Nov 22, 2024
  3. changed the title [-]`beforeValidate` hook runs, but doesn't update UI when during `update` operation[/-] [+]`beforeValidate` hook runs, but doesn't update UI during `update` operation[/+] on Nov 22, 2024
  4. HarleySalas commented on Nov 22, 2024

    @HarleySalas
    Contributor

    I'm also having this issue. in 3.1.0, also with a custom slug field being formatted in a beforeValidate hook. I've used the same exact function in dozens of projects, without issue before.

  5. PeakVisionMediaKLG commented on Nov 23, 2024

    @PeakVisionMediaKLG

    I can verify that I have the same problem on 3.1.0.

  6. rilrom commented on Nov 23, 2024

    @rilrom
    Contributor

    I've gone back and determined it started occurring in beta 128.

  7. removed
    status: needs-triage
    on Nov 27, 2024
  8. github-actions commented on Nov 29, 2024

    @github-actions
    Contributor

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

  9. locked as resolved and limited conversation to collaborators on Nov 29, 2024
  10. github-actions commented on Nov 29, 2024

    @github-actions
    Contributor

    🚀 This is included in version v3.2.2

  11. unlocked this conversation on Nov 29, 2024
  12. locked and limited conversation to collaborators on Nov 29, 2024
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