bug fixes

This commit is contained in:
sairaj mote 2024-02-25 05:25:06 +05:30
parent f6c06deb8b
commit c2c048ec9f
2 changed files with 9 additions and 3 deletions

View File

@ -242,6 +242,7 @@ customElements.define('sm-chips', class extends HTMLElement {
threshold: 1,
});
this.chipsWrapper.addEventListener('option-clicked', e => {
e.stopPropagation();
if (this._value !== e.detail.value) {
this.setSelectedOption(e.detail.value);
this.fireEvent();
@ -361,12 +362,17 @@ customElements.define('sm-chip', class extends HTMLElement {
connectedCallback() {
this.setAttribute('role', 'option');
this.setAttribute('tabindex', '0');
if (!this.hasAttribute('value')) {
console.error('sm-chip must have a value attribute');
}
if (this.hasAttribute('selected'))
this.fireEvent();
this.addEventListener('click', this.fireEvent);
this.addEventListener('keydown', this.handleKeyDown);
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === 'selected') {
if (newValue !== null) {
if (this.hasAttribute('selected')) {
this.fireEvent();
this.setAttribute('aria-selected', 'true');
} else {
@ -380,4 +386,4 @@ customElements.define('sm-chip', class extends HTMLElement {
this.removeEventListener('click', this.fireEvent);
this.removeEventListener('keydown', this.handleKeyDown);
}
});
});

File diff suppressed because one or more lines are too long