Posting this here for posterity, and in case anyone else comes across this. In a custom field and field component, changes from
setValue
via
useField
were not 'enabling' the Save Draft or Publish Changes' buttons. Manually calling
setModified(true)
via
useForm
before calling
setValue
solved the issue. This was only occurring when the custom field was used as a field in a block.
This is weird that that's required. Does that happen to every custom field or only with the lexical one?
Yeah - it was a puzzle for sure. And it only happens in our custom Lexical field FieldComponent and only (I believe) when it's part of a block field. I ran out of time trying to debug it - but I did test as much as I could including setting up a test repo, and at one point using the identical field definition, but with a swapped out field component (using a simpler component) and it worked. Heh. In the end
setModified(true)
just before
setValue({...})
worked fine and apparently without any other side effects and so I've left this as a future 'TODO: Revisit'.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.