From 7db21f413eb729ff7c6598a8212109ca0d5112fb Mon Sep 17 00:00:00 2001 From: Maksym Tsymbarov Date: Mon, 22 Jun 2026 16:35:36 +0200 Subject: [PATCH] Fixed time unit input validation and unwanted dirty state when loading a value (#15822) * Fixed time unit input validation and unwanted dirty state when loading a value * Code improvements --- .../components/time-unit-input.component.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/shared/components/time-unit-input.component.ts b/ui-ngx/src/app/shared/components/time-unit-input.component.ts index 93293698b3..79482f378f 100644 --- a/ui-ngx/src/app/shared/components/time-unit-input.component.ts +++ b/ui-ngx/src/app/shared/components/time-unit-input.component.ts @@ -206,15 +206,13 @@ export class TimeUnitInputComponent implements ControlValueAccessor, Validator, writeValue(sec: number) { if (sec !== this.modelValue) { if (isDefinedAndNotNull(sec) && isNumeric(sec) && Number(sec) !== 0) { - this.timeInputForm.patchValue(this.parseTime(sec), {emitEvent: true}); + this.timeInputForm.patchValue(this.parseTime(sec), {emitEvent: false}); this.modelValue = sec; } else { - this.timeInputForm.patchValue({ - time: 0, - timeUnit: TimeUnit.SECONDS - }, {emitEvent: false}); + this.timeInputForm.patchValue(this.secondsModel(0), {emitEvent: false}); this.modelValue = 0; } + this.refreshTimeValidators(); } } @@ -242,6 +240,14 @@ export class TimeUnitInputComponent implements ControlValueAccessor, Validator, } } } + return this.secondsModel(value); + } + + private secondsModel(time: number): TimeUnitInputModel { + return { + time, + timeUnit: TimeUnit.SECONDS + }; } private createStepMultipleOfValidator(): ValidatorFn {