fix(select-rich): solve case of having singleOption and hassNoDefaultSelected at the same time (#1863)
This commit is contained in:
parent
973b6ff9ac
commit
fd09f652d4
5 changed files with 20 additions and 9 deletions
5
.changeset/chilly-taxis-sin.md
Normal file
5
.changeset/chilly-taxis-sin.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/ui': patch
|
||||
---
|
||||
|
||||
[select-rich] solve case of having singleOption and hasNoDefaultSelected as the same time
|
||||
|
|
@ -384,10 +384,6 @@ const ListboxMixinImplementation = superclass =>
|
|||
updated(changedProperties) {
|
||||
super.updated(changedProperties);
|
||||
|
||||
if (this.formElements.length === 1) {
|
||||
this.singleOption = true;
|
||||
}
|
||||
|
||||
if (changedProperties.has('disabled')) {
|
||||
if (this.disabled) {
|
||||
this.__requestOptionsToBeDisabled();
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ export declare class ListboxHost {
|
|||
|
||||
public hasNoDefaultSelected: boolean;
|
||||
|
||||
public singleOption: boolean;
|
||||
// protected _invokerNode: HTMLElement;
|
||||
|
||||
public checkedIndex: number | number[];
|
||||
|
||||
public activeIndex: number;
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ export class LionSelectRich extends SlotMixin(ScopedElementsMixin(OverlayMixin(L
|
|||
|
||||
/** @protected */
|
||||
_onFormElementsChanged() {
|
||||
this.singleOption = this.formElements.length === 1;
|
||||
this.singleOption = this.formElements.length === 1 && !this.hasNoDefaultSelected;
|
||||
this._invokerNode.singleOption = this.singleOption;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -400,6 +400,19 @@ describe('lion-select-rich', () => {
|
|||
expect(el.singleOption).to.be.false;
|
||||
expect(_invokerNode.singleOption).to.be.false;
|
||||
});
|
||||
|
||||
it('should have singleOption only if one option and no hasNoDefaultSelected', async () => {
|
||||
const el = await fixture(html`
|
||||
<lion-select-rich has-no-default-selected>
|
||||
<lion-option .choiceValue=${10}>Item 1</lion-option>
|
||||
</lion-select-rich>
|
||||
`);
|
||||
|
||||
const { _invokerNode } = getSelectRichMembers(el);
|
||||
|
||||
expect(el.singleOption).to.be.false;
|
||||
expect(_invokerNode.singleOption).to.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
describe('interaction-mode', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue