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 help straight from the Payload team with an Enterprise License.