diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.spec.ts b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.spec.ts index 4dcbceb13..10ff280ae 100644 --- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.spec.ts +++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.spec.ts @@ -93,6 +93,13 @@ describe('CustomFieldsQueryDropdownComponent', () => { expect(component.selectionModel.queries.length).toBe(1) }) + it('should clear on close if model is invalid', () => { + component.selectionModel.clear() + component.selectionModel.addExpression() + component.onOpenChange(false) + expect(component.selectionModel.isEmpty()).toBeTruthy() + }) + it('should support reset the selection model', () => { component.selectionModel.addExpression() component.reset() diff --git a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts index 479f072a1..4137d920e 100644 --- a/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts +++ b/src-ui/src/app/components/common/custom-fields-query-dropdown/custom-fields-query-dropdown.component.ts @@ -274,6 +274,8 @@ export class CustomFieldsQueryDropdownComponent extends LoadingComponentWithPerm this.fieldSelects.first?.focus() }, 0) } + } else if (!this.selectionModel.isValid()) { + this.selectionModel.clear() } }