fix(input-tel-dropdown): sync disabled state to dropdown

This commit is contained in:
gvangeest 2022-04-14 11:27:17 +02:00 committed by Thijs Louisse
parent daea4dd522
commit 8ecfc31c0d
4 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/input-tel-dropdown': patch
---
sync disable state to dropdown for a11y

View file

@ -254,6 +254,14 @@ export class LionInputTelDropdown extends LionInputTel {
if (changedProperties.has('activeRegion')) {
this.__syncRegionWithDropdown();
}
if (changedProperties.has('disabled') || changedProperties.has('readOnly')) {
if (this.disabled || this.readOnly) {
this.refs.dropdown?.value?.setAttribute('disabled', '');
} else {
this.refs.dropdown?.value?.removeAttribute('disabled');
}
}
}
/**

View file

@ -134,6 +134,16 @@ export function runInputTelDropdownSuite({ klass } = { klass: LionInputTelDropdo
);
});
it('syncs disabled attribute to dropdown', async () => {
const el = await fixture(html` <${tag} disabled></${tag}> `);
expect(el.refs.dropdown.value?.hasAttribute('disabled')).to.be.true;
});
it('disables dropdown on readonly', async () => {
const el = await fixture(html` <${tag} readonly></${tag}> `);
expect(el.refs.dropdown.value?.hasAttribute('disabled')).to.be.true;
});
it('renders to prefix slot in light dom', async () => {
const el = await fixture(html` <${tag} .allowedRegions="${['DE']}"></${tag}> `);
const prefixSlot = /** @type {HTMLElement} */ (

View file

@ -0,0 +1 @@
export { runInputTelDropdownSuite } from './LionInputTelDropdown.suite.js';