From bb9d53fd4940810f2af02a4fd65ef3c6fc9a6604 Mon Sep 17 00:00:00 2001 From: Henry Catalini Smith Date: Sat, 28 Mar 2026 20:35:05 +0100 Subject: [PATCH] Add automatic combobox item ID --- src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.ts b/src/index.ts index 35efe6e..d4f2573 100644 --- a/src/index.ts +++ b/src/index.ts @@ -126,6 +126,9 @@ export default class Combobox { el.removeAttribute('data-combobox-option-default') if (target === el) { + if (!target.id) { + target.id = `combobox-item-${Math.random().toString().slice(2, 6)}` + } this.input.setAttribute('aria-activedescendant', target.id) target.setAttribute('aria-selected', 'true') fireSelectEvent(target)