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.

Leave without saving warning in custom component

default discord avatar
rrumslast year
2

Hi all,


I've made an UI field (custom component) that manage changes of others fields.


I noticed that if I change from my custom component then move page, this unsaved warning was not appeared.



Could anyone explain what is the logic behind it? I mean to trigger that warning



Leave without saving warning in custom component



Found myself way to trigger



add this to the component's


import {useForm} from "payload/components/forms";
const {setModified} = useForm()


then in event to handle change


setModified(true)
    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..