Select & boolean fields return null rather than initial value

Hello, we're having an issue with some fields in slices created using Slice Machine.

When we add a slice using the visual editor, many select and boolean fields have a default value, however when the new document is saved (leaving these default values selected and unchanged), the response from the Prismic API for these fields is null, rather than the default value (true/false, or the value in the select field).

The only way to fix it is to select a different value, save the document, change it back to the first value and save the document again.

We can work around the issue by treating a null response as if it's the default value, but it would be great if the API matched what's selected in the visual editor. Is there anything we could be doing wrong that's causing this?

Here you can see dark__green is the default selection, but the slice returned from Prismic has the value null.

Any help would be much appreciated! :slight_smile:

Hello @formfunfunction

Thanks for reaching out to us.

Did you try to update to the beta: npm install slice-machine-ui@beta

Please find the complete information in this thread.

Let me know if it still doesn't solve the issue.


Just wanted to flag that this has been a problem ever since I've been using Prismic, not only with slice machine

Hello @kris

This should be fixed now with the Slice Machine project. Did you try with the Slice Machine?


Hi @Priyanka

Thanks for the reply! My project has always been using the beta version of slice-machine-ui. My yarn.lock file references 0.1.0-beta.2.

I just double-checked I was on the latest version anyway, made sure the defaults were all set correctly on my slice, re-saved and pushed the slice, but when I create a new document all the select and boolean fields are still null.

Hello @formfunfunction

Sorry for the late response. I was on the vacation. Can you please send me the URL of your repository? You can send me a private message.


Hello @formfunfunction

I have checked with the dedicated developer, and he suggested the following solutions.
Saving boolean fields again should fix it:

  1. Go to your Custom Type
  2. Edit the boolean field and toggle "default to true" and save
  3. Reload the custom type: the default value should still be set to true
  4. Create a new document and save it
  5. Check the value of the field: it should be set to true by default

Please try with this and let me know ow if you still have any issues.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.