Why do repeatable groups insist on being initialized with at least one null item?

Hello,

I have a doc type that contains a repeatable group representing links. It contains two key text fields called "text" (what will be displayed for the link) and "url" (where the link will take you when clicked):

When I create a new document based on this type, it insists on populating the group list with at least one link with null for text and url:

Why is this?

This is forcing me to check that the text or url have actual values in my code since I cycle through the links in a foreach loop. I was expecting that it would skip the foreach loop if the Prismic content editor had no links to add to the document, but because it is initialized with at least one, it enters the foreach loop and I have to check.

I realize I can just easily delete the default link on creating new documents, but is there a way to set it so that it leaves the list initially empty? That way, I don't have to worry about content editors not knowing to delete the default link.

Thanks.

Hello,

Thank you for contacting us.

Currently, by default, at the time of document creation, group field will have one list item inside it, which will return null, this is the expected behaviour of the API response. To get the empty list, only option is to delete this list item in the group field, as you are already doing. I'd suggest to you use slices instead group to avoid this issue.

Although, we will consider this as part of our future developments as it's a good idea to have an empty list in a repeatable group field by default.

Thanks,
Priyanka