link attributes widget generates the same id for all select elements

Issue information

From user: Bcwald

Contribution record

Fork management

Hi, I am working on an admin theme and an issue came up in the queue with someone working with link_attributes. https://www.drupal.org/project/material_admin/issues/2931557

Essentially, if you have a link field that can have multiple instances, the
element for "target" always generates the exact same ID (target) on each new element, which causes invalid markup because of multiple instances of the same ID.

I rely on the ID so that I can move the select element before the label when necessary. I am working on a solution for better handling unknown markup but I figured I would create an issue for this project while I am at it, since this still is a bug in the module.

Reproduce steps:

- Create a link field on a node -> set the 'allowed number of values' to 'unlimited'.
- Set the form display widget to use link attributes
- create multiple values of that field. Inspect the elements.
- see all
elements have the same ID of "target".

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information