From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 27 Oct 2024 13:53:59 +0000 (-0700) Subject: Fix: fix custom field query empty element removal (#8056) X-Git-Tag: v2.13.1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2e9f3195a38d387f7fabd24744d092e7800964e;p=thirdparty%2Fpaperless-ngx.git Fix: fix custom field query empty element removal (#8056) --- 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 dbd269b3b6..b0d446dd0b 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) {