Skip to content

Commit ab89ceb

Browse files
authored
fix(chip): Uses correct aria role in a selection-mode:none Chip Group (#6862)
## Summary Handles the case where a parent Chip Group of `selection-mode="none"` caused the Chip to incorrectly have role of "radio" set. cc @geospatialem
1 parent 3ba1b50 commit ab89ceb

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/components/chip/chip.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,22 @@ export class Chip
375375

376376
render(): VNode {
377377
const disableInteraction = this.disabled || (!this.disabled && !this.interactive);
378+
const role =
379+
this.selectionMode === "multiple" && this.interactive
380+
? "checkbox"
381+
: this.selectionMode !== "none" && this.interactive
382+
? "radio"
383+
: this.interactive
384+
? "button"
385+
: undefined;
378386
return (
379387
<Host>
380388
<div
381-
aria-checked={this.interactive ? toAriaBoolean(this.selected) : undefined}
389+
aria-checked={
390+
this.selectionMode !== "none" && this.interactive
391+
? toAriaBoolean(this.selected)
392+
: undefined
393+
}
382394
aria-disabled={disableInteraction ? toAriaBoolean(this.disabled) : undefined}
383395
aria-label={this.label}
384396
class={{
@@ -397,13 +409,7 @@ export class Chip
397409
(!!this.selectionMode && this.selectionMode !== "multiple" && !this.selected))
398410
}}
399411
onClick={this.handleEmittingEvent}
400-
role={
401-
this.selectionMode === "multiple" && this.interactive
402-
? "checkbox"
403-
: this.interactive
404-
? "radio"
405-
: undefined
406-
}
412+
role={role}
407413
tabIndex={disableInteraction ? -1 : 0}
408414
// eslint-disable-next-line react/jsx-sort-props
409415
ref={(el) => (this.containerEl = el)}

0 commit comments

Comments
 (0)