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"

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

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

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

Thanks