Tina Sidebar - is there any way to have the boolean inside the config?

I have this for my strapi/nextJS and Tina website

            new TinaCMS({
                // Only enable for those with permissions
                enabled: pageProps.preview,
                toolbar: pageProps.preview,
                sidebar: {
                     position: 'overlay'
                },
                apis: {
                    strapi: new StrapiClient(process.env.STRAPI_URL)
                },
                media: {
                    store: new StrapiMediaStore(process.env.STRAPI_URL)
                }
            }),

If pageProps is false so TinaCMS = enabled:false – but the sidebar being set without a separate boolean, seems to re-enable TinaCMS. This creates a bug where I’m stuck in edit mode on loop, but preview mode is false, so all edits appear to be saved on the front end but they never get saved to Strapi!

I think either the sidebar needs to be able to be explicitly set to true or false.

It works fine if I just do sidebar: pageProps as then it is false when it should be, but I want to use overlay because displacing the content can cause issues with calc based styles.

Is there some workaround for this? If not I will raise it as an issue.

That is really odd behaviour. I definitely want to check it out.

That said you could probably do this:

            new TinaCMS({
                // Only enable for those with permissions
                enabled: pageProps.preview,
                toolbar: pageProps.preview,
-               sidebar: {
+               sidebar: pageProps.preview && {
                     position: 'overlay'
                },
                apis: {
                    strapi: new StrapiClient(process.env.STRAPI_URL)
                },
                media: {
                    store: new StrapiMediaStore(process.env.STRAPI_URL)
                }
            }),

That will set sidebar=false when preview is false but it will set it to the config object when true.

1 Like

Oh yeah! I was thinking I am inside a json file or something, ofc.

Cheers Nolan :pray:

FYI this did come up in a slightly different form. Same cause though. Here’s the GitHub Issue

1 Like

Here’s a PR fixing the issue @ncphi shared

2 Likes