I've noticed an issue that boolean fields created in Slice Machine with a default set do not publish the default when authoring. Comes out null. In order to get a response, I have to toggle the switch at least once when authoring the content. Anyone else experience this?
Thanks for pointing this out, I'm going to bring it up with the team. To help me reproduce this error, can you give me your repo URL?
Yes, slicemachinetest.prismic.io and is happening in my ArticleSummary shared slice. I have a boolean control that is set to true by default (using the checkbox in Slice Machine that says "defualt to true") that sets the image on the left or the right. It was returning null for the ones I didn't modify instead of returning the default of true. I had to physically go into the editor and toggle the switch at least once to get a response that wasn't null. Seems like it might be a bug. Please let me know if you find anything on my end that would cause that. Thanks.
Hey again Shawn,
For this one are you saying that you added the boolean and then needed to go to old documents and republish them so that the boolean isn't null?
Or that even if you create a new document you need to toggle the boolean field to not have a null response?
Creating a brand new document the boolean is returning null unless I physically toggle the switch. Seems the default doesn't get passed through.
@Phil @alws Just created another document with two instances of this slice. On the first one, I left the default with was true and on the other I toggled it to false. In my vue dev tools I see the this for the first response:
slice:Object items:Array primary:Object description:Array image:Object isAlignedLeft:null link:Object linkLabel:Array title:Array slice_label:null slice_type:"article_summary" variation:"default-slice" version:"sktwi1xtmkfgx8626"
As you can see "isAlignedLeft" is null. But on the second instance, that I physically toggled to false:
slice:Object items:Array primary:Object description:Array image:Object isAlignedLeft:false link:Object linkLabel:Array title:Array slice_label:null slice_type:"article_summary" variation:"default-slice" version:"sktwi1xtmkfgx8626"
OK, that's sounds like a bug then. I'll need to bring this up with the team.
I've passed this on to the team they'll update you here if we have anymore info. Though I think this might be related to state not being set in Slices automatically in general, like this date field issue Timestamp inside slice - possible to use default: now?
This is being tracked as an open feature request.
A post was merged into an existing topic: Add ability to include a Default Value to fields in the content builder
@skedify This should be fixed now. Please update to the latest:
npm install slice-machine-ui@latest
It seems it was actually an issue with the custom types. Saving boolean fields again should fix it:
- Go to your Custom type
- Edit the boolean field and toggle "default to true" and save
- Reload the custom type: the default value should still be set to true
- Create a new document and save it
- Check the value of the field: it should be set to true by default