-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): addFieldRow set modified (#9324)
Fixes #9264. When externally updating array or block rows through the `addFieldRow` or `replaceFieldRow` methods, nested rich text fields along with any custom components within them are never rendered. This is because unless the form is explicitly set to modified, as the default array and blocks fields currently do, the newly generated form-state will skip the rendering step. Now, the underlying callbacks themselves automatically set the form to modified to trigger rendering.
- Loading branch information
1 parent
a50029f
commit 0f3f6e7
Showing
9 changed files
with
93 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use client' | ||
|
||
import { useForm } from '@payloadcms/ui' | ||
|
||
const AddRowButton = () => { | ||
const { addFieldRow } = useForm() | ||
|
||
const handleClick = () => { | ||
addFieldRow({ | ||
path: 'externallyUpdatedArray', | ||
schemaPath: 'externallyUpdatedArray', | ||
subFieldState: { | ||
text: { | ||
initialValue: 'Hello, world!', | ||
valid: true, | ||
value: 'Hello, world!', | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
return ( | ||
<button id="updateArrayExternally" onClick={handleClick} type="button"> | ||
Add Row | ||
</button> | ||
) | ||
} | ||
|
||
export default AddRowButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { TextFieldServerComponent } from 'payload' | ||
|
||
import { TextField } from '@payloadcms/ui' | ||
|
||
export const CustomField: TextFieldServerComponent = ({ clientField, path }) => { | ||
return ( | ||
<div id="custom-field"> | ||
<TextField field={clientField} path={path as string} /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters