fix(input-tel-dropdown): sync disabled state to dropdown
This commit is contained in:
parent
daea4dd522
commit
8ecfc31c0d
4 changed files with 24 additions and 0 deletions
5
.changeset/rotten-birds-call.md
Normal file
5
.changeset/rotten-birds-call.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/input-tel-dropdown': patch
|
||||
---
|
||||
|
||||
sync disable state to dropdown for a11y
|
||||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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} */ (
|
||||
|
|
|
|||
1
packages/input-tel-dropdown/test-suites/index.js
Normal file
1
packages/input-tel-dropdown/test-suites/index.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { runInputTelDropdownSuite } from './LionInputTelDropdown.suite.js';
|
||||
Loading…
Reference in a new issue