Changing the value of one field in group-list resets the other

TinaCMS is a great piece of software, but having only dealt with it for one work-day so far I don’t really know of any further ways of debugging this issue I’m having:

The opposing field to the one I’m editing resets as soon as I edit the other. Let’s say I changed the “Tittel”-field to have “Hello world” as it’s value and then went to change the “Lenke”-field, then it would reset the “Tittel”-field back to its original content.

Below is my code:

const site = useCurrentSite()
const [data, form] = useForm(
    {
        id: componentId,
        label: "Rediger navigasjon",
        fields: [
            {
                label: "Lenker",
                name: "links",
                component: "group-list",
                itemProps: item => ({
                    key: item.id,
                    label: `${item.title} (${item.link})`,
                }),
                defaultItem: () => ({
                    title: "Ny lenke",
                    id: Math.random().toString(36).substr(2, 9),
                    link: "#" + Math.random().toString(36).substr(2, 9),
                }),
                fields: [
                    {
                        label: "Tittel",
                        name: "title",
                        component: "text",
                    },
                    {
                        label: "Lenke",
                        name: "link",
                        component: "text",
                    },
                ],
            },
        ],
        initialValues: {
            links: site.navbar,
        },
        onSubmit: async data => {
            await updateNavbar(data.links, site.websiteDatabasePath)
        },
    },
    {
        values: {
            links: site.navbar,
        },
    }
)

Resolved, just needed to separate it out in a useState-hook.

1 Like