Skip to content

Freeform and default tags can receive duplicate IDs #6

Description

@alx-so

Problem

Tag IDs generated for freeform and default tags are based on new Date().getTime(). Multiple tags created in the same millisecond can receive the same ID.

This is likely when composing several default tags during initial render, and it can also happen when adding tags quickly through imperative or UI flows.

Impact

Duplicate IDs are used as React keys and as the removal identity. If two tags share an ID, React can warn about duplicate keys, render the tag list incorrectly, or remove more than one tag when the user removes a single tag.

Code references

  • src/components/Input/utils.ts#L13-L23: composeTags() maps multiple labels through composeTagItem().
  • src/components/Input/utils.ts#L25-L30: composeTagItem() uses new Date().getTime() as the ID.
  • src/components/Input/Input.tsx#L160-L168: tags use tag.id as the React key.
  • src/components/Input/Input.tsx#L204-L210: tag removal filters by tag.id.
  • src/components/Input/InputEnhanced.tsx#L9-L14: freeform add flow also generates an ID from the current timestamp.

Acceptance criteria

  • Generated tag IDs are stable and unique for tags created in the same render or user interaction window.
  • Removing one generated tag removes only that tag.
  • Default tags created from a string array do not produce duplicate keys.
  • Regression tests cover multiple default tags and rapid generated tag insertion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: multiselectMultiple selection and tag behaviorbugSomething isn't workingpriority: highHigh impact issue for the next release

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions