Skip to content

Commit b7fe8c9

Browse files
authored
Merge pull request #635 from gselderslaghs/chips-accessibility
accessibility(Chips)
2 parents 668bd0b + 3dc3ddc commit b7fe8c9

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

components/chips/_chips.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
margin: 0;
1414
height: 32px;
1515
padding-left: var(--padding);
16-
padding-right: var(--padding);
16+
padding-right: var(--padding);
1717
font-size: var(--font-size);
18-
font-weight: 500;
18+
font-weight: 500;
1919
border-radius: 8px;
2020
align-items: center;
2121
user-select: none;
@@ -49,6 +49,7 @@
4949
}
5050

5151
.chip .close {
52+
border: none;
5253
border-radius: 50%;
5354
height: 24px;
5455
width: 24px;

components/chips/chips.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ export class Chips extends Component<ChipsOptions> {
124124
this.chipsData = this.options.data;
125125
this._renderChips();
126126
}
127-
this._setupLabel();
128127

129128
// Render input element, setup event handlers
130129
if (this.options.allowUserInput) {
130+
this._setupLabel();
131131
this.el.classList.add('input-field');
132132
this._setupInput();
133133
this._setupEventHandlers();
@@ -299,9 +299,9 @@ export class Chips extends Component<ChipsOptions> {
299299
}
300300
};
301301

302-
_renderChip(chip: ChipData): HTMLDivElement {
302+
_renderChip(chip: ChipData): HTMLLIElement {
303303
if (!chip.id) return;
304-
const renderedChip = document.createElement('div');
304+
const renderedChip = document.createElement('li');
305305
renderedChip.classList.add('chip');
306306
renderedChip.innerText = chip.text || <string>chip.id;
307307
// attach image if needed
@@ -311,11 +311,10 @@ export class Chips extends Component<ChipsOptions> {
311311
renderedChip.insertBefore(img, renderedChip.firstChild);
312312
}
313313
if (this.options.allowUserInput) {
314-
renderedChip.setAttribute('tabindex', '0');
315-
const closeIcon = document.createElement('i');
316-
closeIcon.classList.add(this.options.closeIconClass, 'close');
317-
closeIcon.innerText = 'close';
318-
renderedChip.appendChild(closeIcon);
314+
const closeButton = document.createElement('button');
315+
closeButton.classList.add(this.options.closeIconClass, 'close');
316+
closeButton.innerText = 'close';
317+
renderedChip.appendChild(closeButton);
319318
}
320319
return renderedChip;
321320
}

0 commit comments

Comments
 (0)