Repository navigation
Closed
Description
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
Reproduction Steps
-
Clone Repo
git clone [email protected]:yulolimum/tmp-payload-before-validate-repro.git
-
Install Deps
cd tmp-payload-before-validate-repro yarn -
Start Dev Server
yarn dev
-
Login
- user:
[email protected] - pass:
repro
- user:
-
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".
-
Update the User
- Change the "Demo Field" to any text and click "Save". Observe - field remains with the same text you typed.
-
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
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]`beforeValidate` hook runs, but doesn't update UI when during `update` operation[/-][+]`beforeValidate` hook runs, but doesn't update UI during `update` operation[/+]HarleySalas commentedon Nov 22, 2024
I'm also having this issue. in
3.1.0, also with a custom slug field being formatted in abeforeValidatehook. I've used the same exact function in dozens of projects, without issue before.PeakVisionMediaKLG commentedon Nov 23, 2024
I can verify that I have the same problem on 3.1.0.
rilrom commentedon Nov 23, 2024
I've gone back and determined it started occurring in beta 128.
fix: incorrect formState after doc save (#9573)
github-actions commentedon Nov 29, 2024
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.
github-actions commentedon Nov 29, 2024
🚀 This is included in version v3.2.2
fix: incorrect formState after doc save (#9573)