Skip to content

[BUG] Multiple checkboxes with same ID are unusable #497

@kevin-carangeot

Description

@kevin-carangeot

Context

If I have multiple PUIK elements on my page, it is possible for some to share the same ID due to the generateId() function in puik-utils (there is a 1 in 1000 chance, but it still happens 😬).

Steps to Reproduce

  1. Create multiple puik-checkbox elements.
  2. Reload the page until 2 checkboxes have the same ID.
  3. The checkbox becomes unusable when clicking on the label.

Expected Behavior

I should be able to click on any label, and it should check the correct checkbox.

Current Behavior

When I click on a label that shares an ID with another, it checks the wrong checkbox.

Additional Comments

The generateId() function in puik-utils does not generate a unique ID.
A UUID should be generated instead of a random number between 1 and 1000 to ensure it is truly unique.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions