Duplicate option and cardinality limit challenges in link and entity reference fields

Created on 27 October 2023, about 1 year ago

Problem/Motivation

In the Drupal Link module's Link field and entity reference fields, there is an issue with the Duplicate option when a cardinality limit is set. The problem is twofold:

  1. In the Link module's Link field, the Duplicate option continues to work even if the limit is reached, leading to unexpected behavior.
  2. In entity reference fields, specifically when duplicating entities, the Duplicate option disappears when the cardinality limit is reached. Even if references are removed, the Duplicate option doesn't reappear, creating a usability issue.

Steps to reproduce(Link Field)

  1. Create a content type with a Link reference field.
  2. Set the cardinality limit for this field to 3.
  3. Add three items to the Link field.
  4. Attempt to duplicate one of the existing links.
  5. Observe that the duplication succeeds, resulting in a total of four items in the field, exceeding the intended limit.

Steps to reproduce(Entity Reference Field)

  1. Add an entity reference field with a specific cardinality limit.
  2. Create references to reach the cardinality limit.
  3. Attempt to duplicate the entity, and observe the "Duplicate" option disappearing.
  4. Remove one or more existing references.
  5. Notice that the "Duplicate" option doesn't reappear, even though the cardinality limit is no longer reached.

Proposed resolution

The proposed resolution is to update the behavior of the Duplicate option in both the Link module's Link field and entity reference fields as follows:

  1. For the Link module's Link field:
    • If the cardinality limit is 1, the Duplicate option should not be displayed in the dropdown menu when the limit is reached.
    • When the cardinality limit is greater than 1, the Duplicate option should be available up to the specified limit. If the limit is reached, the Duplicate option should be disabled.
  2. For entity reference fields:
    • The "Duplicate" option should be designed to reappear if a reference is removed from the list, even after reaching the cardinality limit. This enhancement would provide a more user-friendly experience, allowing users to duplicate entities when they free up space within the reference field by removing existing references.

Additionally, consider enhancing the Link module by providing a configuration option that allows site administrators to control the behavior of the Duplicate option, similar to how it is done in the Paragraph field. This enhancement will provide greater flexibility for site administrators to customize the behavior of the Duplicate option based on their specific needs.

🐛 Bug report
Status

Active

Version

1.16

Component

Code

Created by

🇮🇳India adhershmnair Trivandrum

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024