[Bug?] Sometimes the Link field returns wrong UID in document.slug

When selecting a document in a Link field it's not always returning the corresponding valure from the UID field in slice,primary.document.slug if there is another slice in this document.

It looks like slice,primary.document.uid is alway the correct UID value.

My document looks like this:

{
  ...,
  "json": {
    "Main": {
      "title": {
        "config": {
          "label": "Title",
          "placeholder": ""
        },
        "type": "Text"
      },
      "uid": {
        "config": {
          "label": "Slug",
          "placeholder": ""
        },
        "type": "UID"
      },
      "slices": {
        "type": "Slices",
        "fieldset": "Slice Zone",
        "config": {
          "choices": {
            "test": {
              "type": "SharedSlice"
            }
          }
        }
      }
    },
    ...
  }
}

Documents with only Title and Slug values are retuning the correct UID value when rendering slice.primary.document.slug.

{
  ...
  primary: {
    ...
    document: {
      slug: 'another-test-page',
      uid: 'another-test-page',
      ...
    }
  }
}

Documents with Title, Slug and Slices values are returning the slice.primary.title value when rendering slice.primary.document.slug.

{
  ...
  primary: {
    ...
    document: {
      slug: 'test-slice-title',
      uid: 'test-page',
      ...
    }
  }
}

This is the case for both Non-Repeatable Zone (slice,primary.document.slug) and Repeatable Zone (slice.items[x].document.slug).

Edit: I'm using Nextjs.

{
  "@prismicio/client": "^6.4.2",
  "@prismicio/helpers": "^2.2.1",
  "@prismicio/next": "^0.1.2",
  "@prismicio/react": "^2.2.0",
  "@prismicio/slice-simulator-react": "^0.2.1",
  "next": "12.1.4",
  "react": "18.0.0",
  "react-dom": "18.0.0"
}

Hello @jordy, thanks for reaching out.

You should always use the UID field and ignore the slug, as it is a legacy field that we haven't removed from the response:

Thanks