From be450b5a75d9baa8630ca040dea1a9b9a98425cd Mon Sep 17 00:00:00 2001 From: SnehaRH Date: Tue, 17 Feb 2026 13:06:22 +0530 Subject: [PATCH] fix: resolve Allocate Batches flickering when toggling System/Manual Issue radio buttons Set allocated flag synchronously before async API call and move allocate() outside forEach loop to prevent redundant requests and UI flicker. Co-Authored-By: Claude Opus 4.6 --- .../rx-item-dispense/rx-item-dispense.component.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/app-modules/rx/rx-item-dispense/rx-item-dispense.component.ts b/src/app/app-modules/rx/rx-item-dispense/rx-item-dispense.component.ts index 0da22da..09207cc 100644 --- a/src/app/app-modules/rx/rx-item-dispense/rx-item-dispense.component.ts +++ b/src/app/app-modules/rx/rx-item-dispense/rx-item-dispense.component.ts @@ -202,22 +202,25 @@ export class RxItemDispenseComponent implements OnInit, OnChanges, DoCheck { this.clearBatchArray(selectionBatchList); if (this.issueType === 0) { - console.error('Issue Type is 0, allocating batches', this.issueType); - this.allocate(); - this.allocated = false; element.preDefinedBatchList.forEach((batch: any) => { selectionBatchList.push( this.utils.initBatchListElement(batch, this.issueType), ); }); - } else if (this.issueType === 1) { - this.allocate(); } currentGroup.patchValue({ qtyDispensed: null, }); currentGroup.controls['selectionBatchList'] = selectionBatchList; }); + + if (this.issueType === 0) { + this.allocated = false; + this.allocate(); + } else if (this.issueType === 1) { + this.allocated = true; + this.allocate(); + } } clearBatchArray(formArray: any) {