I have a navigation slice that only contains a link field, I noticed that when i copy/paste a slice, the key property of that field is duplicated as well.
For example, i copied the “Instagram“ slice and then pasted and renamed the second one as “Pinterest“, but both Link fields share the same key value in API response:
Hey there! where exactly are you pasting this, inside a repeatable slice zone on a page? Or inside a Rich Text field? And are you copying the entire slice, or just duplicating it from within the Page Builder UI?
Hi, sorry for the late reply! I copy and paste the entire slice inside the same page, from the ui i click the three dots on the slice, then “copy” and then “paste”
When you copy/paste a slice from the Page Builder UI, the internal key of the link field is duplicated as well. That key is tied to the field instance and isn’t regenerated when duplicating the slice.
However, each slice instance has its own id in the API response. So even if the link key is the same after copying, the slice id will always be different.
If you need a reliable way to differentiate between duplicated slices in your frontend logic, we recommend using the slice id instead of the link key.