From b2e9f3195a38d387f7fabd24744d092e7800964e Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 27 Oct 2024 06:53:59 -0700 Subject: [PATCH] Fix: fix custom field query empty element removal (#8056) --- .../custom-fields-query-dropdown.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 dbd269b3b..b0d446dd0 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 @@ -114,16 +114,21 @@ export class CustomFieldQueriesModel { queryElement: CustomFieldQueryElement, elements: any[] ): CustomFieldQueryElement { + let foundElement for (let i = 0; i < elements.length; i++) { if (elements[i] === queryElement) { - return elements.splice(i, 1)[0] + foundElement = elements.splice(i, 1)[0] } else if (elements[i].type === CustomFieldQueryElementType.Expression) { - return this.findElement( + foundElement = this.findElement( queryElement, elements[i].value as CustomFieldQueryElement[] ) } + if (foundElement) { + break + } } + return foundElement } public removeElement(queryElement: CustomFieldQueryElement) {