mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[AAE-11654] Fix default option being selectable when parent dropdown … (#8146)
* [AAE-11654] Fix default option being selectable when parent dropdown has no option selected * [AAE-11654] Remove comment
This commit is contained in:
parent
0ab39e28fd
commit
1f450c0593
@ -501,10 +501,7 @@ describe('DropdownCloudWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await openSelect('child-dropdown-id');
|
await openSelect('child-dropdown-id');
|
||||||
|
|
||||||
const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]'));
|
expect(widget.field.options).toEqual([]);
|
||||||
expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]);
|
|
||||||
expect(defaultOption.context.value).toBe(undefined);
|
|
||||||
expect(defaultOption.context.viewValue).toBe('Choose one...');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch the options from a rest url for a linked dropdown', async () => {
|
it('should fetch the options from a rest url for a linked dropdown', async () => {
|
||||||
@ -631,10 +628,7 @@ describe('DropdownCloudWidgetComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await openSelect('child-dropdown-id');
|
await openSelect('child-dropdown-id');
|
||||||
|
|
||||||
const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]'));
|
expect(widget.field.options).toEqual([]);
|
||||||
expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]);
|
|
||||||
expect(defaultOption.context.value).toBe(undefined);
|
|
||||||
expect(defaultOption.context.viewValue).toBe('Choose one...');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Manual - On parent value changes (chain)', () => {
|
describe('Manual - On parent value changes (chain)', () => {
|
||||||
|
@ -138,7 +138,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
|||||||
this.isValidRestType() ? this.persistFieldOptionsFromRestApi() : this.persistFieldOptionsFromManualList(value);
|
this.isValidRestType() ? this.persistFieldOptionsFromRestApi() : this.persistFieldOptionsFromManualList(value);
|
||||||
} else if (this.isNoneValueSelected(value)) {
|
} else if (this.isNoneValueSelected(value)) {
|
||||||
this.resetRestApiErrorMessage();
|
this.resetRestApiErrorMessage();
|
||||||
this.addDefaultOption();
|
this.resetOptions();
|
||||||
this.resetInvalidValue();
|
this.resetInvalidValue();
|
||||||
} else {
|
} else {
|
||||||
this.field.options = [];
|
this.field.options = [];
|
||||||
@ -196,8 +196,8 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
|||||||
return !!this.field.rule.entries.length;
|
return !!this.field.rule.entries.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private addDefaultOption() {
|
private resetOptions() {
|
||||||
this.field.options = [DEFAULT_OPTION];
|
this.field.options = [];
|
||||||
this.updateOptions();
|
this.updateOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user