Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Custom Component Changes Not Enabling Save Draft or Publish Changes

default discord avatar
58bitslast year
2

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.

  • discord user avatar
    alessiogr
    last year

    This is weird that that's required. Does that happen to every custom field or only with the lexical one?

  • default discord avatar
    58bitslast year

    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 on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.