Skip to content

Commit 65a9b7f

Browse files
committed
fix: Don’t rely on 'id' which is possibly not globally-unique
1 parent f38b828 commit 65a9b7f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ActionList/Item.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,12 @@ export function Item(itemProps: Partial<ItemProps> & {item?: ItemInput}): JSX.El
307307
onKeyPress,
308308
children,
309309
onClick,
310-
id: _id,
310+
id,
311311
...props
312312
} = itemProps
313313

314-
const id = useMemo(() => _id ?? uniqueId(), [_id])
314+
const labelId = useMemo(() => uniqueId(), [])
315+
const descriptionId = useMemo(() => uniqueId(), [])
315316

316317
const keyPressHandler = useCallback(
317318
event => {
@@ -357,8 +358,8 @@ export function Item(itemProps: Partial<ItemProps> & {item?: ItemInput}): JSX.El
357358
variant={variant}
358359
showDivider={showDivider}
359360
aria-selected={selected}
360-
aria-labelledby={text ? `${id}-label` : undefined}
361-
aria-describedby={description ? `${id}-description` : undefined}
361+
aria-labelledby={text ? labelId : undefined}
362+
aria-describedby={description ? descriptionId : undefined}
362363
{...props}
363364
data-id={id}
364365
onKeyPress={keyPressHandler}

0 commit comments

Comments
 (0)