From 2bbb4206ea2f048763e8b0f8d2211c9ff776d6d0 Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Mon, 6 Dec 2021 10:10:34 -0700 Subject: [PATCH] loop backwards --- .../components/form-object/form-object.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/src/app/components/form-object/form-object.component.ts b/ui/src/app/components/form-object/form-object.component.ts index 2dae520d5..b5a551114 100644 --- a/ui/src/app/components/form-object/form-object.component.ts +++ b/ui/src/app/components/form-object/form-object.component.ts @@ -237,11 +237,11 @@ export class FormObjectComponent { private updateEnumList (key: string, current: string[], updated: string[]) { this.formGroup.get(key).markAsDirty() - current.forEach((val, index) => { - if (!updated.includes(val)) { - this.deleteListItem(key, index, false) + for (let i = current.length - 1; i >= 0; i--) { + if (!updated.includes(current[i])) { + this.deleteListItem(key, i, false) } - }) + } updated.forEach(val => { if (!current.includes(val)) { @@ -250,7 +250,7 @@ export class FormObjectComponent { }) } - private getDocSize (selected: string) { + private getDocSize (selected: string) { const element = document.getElementById(selected) return `${element.scrollHeight}px` }