Problem/Motivation

Typing a term that is already in the field and pressing Enter adds it a second time, and the list offers it as a new term while it is sitting right there.

Steps to reproduce

  1. Add a term to an Autocomplete Deluxe field.
  2. Type the same term again and press Enter.
  3. The term is added twice.

Proposed resolution

Compare the typed value with the labels that are already in the field, with the trailing entity ID taken off, and refuse the duplicate.

One tag after typing the same term twice

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Developer Documentation
  • ➖ User Guide Documentation
  • ➖ Reviewed by human
  • ➖ Code review by maintainers
  • ➖ Full testing and approval
  • ➖ Credit contributors
  • ➖ Review with the product owner
  • ➖ Release notes snippet
  • ❌ Release

User interface changes

  • The same term cannot be added twice.

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • The same term cannot be added twice.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

axaios created an issue. See original summary.

fotidim’s picture

Version: 8.x-1.x-dev » 8.x-1.0-beta1
Component: Single values » Code (miscellaneous)
ioana apetri’s picture

StatusFileSize
new42.14 KB

I checked this behavior, and when I try to add the same term twice, it doesn't appear, so it looks like this is not an issue.

rajab natshah’s picture

Version: 8.x-1.0-beta1 » 2.0.x-dev

rajab natshah’s picture

Version: 2.0.x-dev » 2.1.x-dev
Assigned: Unassigned » rajab natshah
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new65.46 KB

Thank you, Foti for reporting and Ioana for checking it again.

Both readings are right. The suggestion list does hide a term that is in the field, which is what Ioana saw. Typing that term again and pressing Enter still added a second tag, because the typed text carries no entity ID while the item is stored under Label (7).

Tested on Drupal 11.4. With the merge request, picking Drupal and then typing Drupal and Enter leaves one tag, and a genuinely new term is still added.

One tag after typing the same term twice

To review, test, then merge.

rajab natshah’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Assigned: rajab natshah » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.