Default option in select field is not working

Hello,

I have a background select field with two options - white and dark. The "white" option is the default one.

I expect that if I don't touch the field within the Prismic writing room, it would be "white" by default. However, this is not the case - instead it outputs as "undefined". Only when I go to the dashboard, open the dropdown, select "dark", then back to "white", it renders the correct value.

The "undefined" value impacts the UI of my app so it's crucial for the default value to be "white"

3 Likes

Hello @kris, thanks for reaching out.

I believe this is because pushing Custom Type changes to your repository won't trigger an update inside the documents. If the document already existed and you add a new field, you need to perform a change inside of it to see the default field reflected.

These changes should be manual, so there are no unexpected document changes, redeploys, webhooks being fired, etc. An editor always triggers changes.

@Pau This is happening to documents who already have had this field and I haven't made any changes to the custom type. Two case scenarios

  1. I create a new document with a slice that has this field
  2. I update an already existing document with the new slice

@Pau I just tested it further and it seems to be happening only if the select field is in a slice. If it's in the static zone, it's rendered correctly from the start without manually having to change the field in order for it to take effect.

Hey @kris, Thanks a lot for the additional information. We'll run a test on our end and open an issue in our backlog when we're able to reproduce it.

@Pau I just noticed that the same thing is happening with Boolean fields.

I need to manually change the field back and forward in order for the field to be updated.

I'd consider this a critical bug as it says one thing within the Prismic writing room while the API delivers another information. Content writers can be confused by it

2 Likes

I understand, thanks for sharing this additional info.
I'll add it to the same ticket.
Whenever we have an update we'll update this same thread.

Thanks

Hey @Pau We're seeing this issue too, any updates on this one? Thanks

1 Like

Hello, @will
There is no news at the moment.
We'll post an update whenever there is.

Thanks

@Pau Are there any updates on this? I reported this bug over a month ago but unfortunately it's still a production bug that impact real websites. It showcases different values in the content room and the API. This confuses not only the content person, but also me as a developer. But it also impacts the slices themselves, as I haven't (and shouldn't since it has a default value) accounted for "undefined" value

1 Like

Hello @kris, we don't have any news just yet, sorry for the inconvenience. We will come back to you as we get any updates.

Thanks,
Priyanka

Jumping on this thread to report the same issue for our team at Arcadia.com.

At the Prismic team's encouragement, we took a leap of faith with Slice Machine, but bugs like this make it hard to get and maintain buy-in from content teams as well as the developers who support them.

3 Likes

Hello @dan.duett

I agree the bug is crucial and needs improvement. Our team is continuously working on improving SM for a better developer and content editor experience. I'll share your feedback with them.

Thanks,
Priyanka

1 Like

Jumping on as well. Getting unexpected null values from booleans and selects adds complexity all over our code.

@jerry.nummi which version of Slice Machine are you using?

0.4.1

Thanks @jerry.nummi, I can confirm this issue is still on the backlog.
Sorry for the inconvenience.
We'll update this thread whenever there's news.

Hello,

Quick update, I worked on a fix today, I’ll make sure to release it this week, I’ll keep you guys informed here.

It’s now partially deployed on production, please contact me in private message so we can activate the fix on your repository and make sure it runs smoothly for you guys @will @jerry.nummi @dan.duett @kris

Arnaud.

1 Like