From 77dce0344784f90f409d0da57c09f435d343b630 Mon Sep 17 00:00:00 2001 From: Jialecl Date: Tue, 25 Jan 2022 16:24:20 +0100 Subject: [PATCH 1/2] [Patch] fixing number events behaviour --- .../src/lib/dxc-number-input/dxc-number-input.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts b/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts index bdef40a88..b8216b698 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts @@ -220,12 +220,12 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy { this.onChange.emit(event); this.controlled ? (this.dxcInputRef.inputRef.nativeElement.value = this.value) - : (this.value = event); + : (this.value = event.value); } handleOnBlur(event) { this.validationError = this.validateOnBlur(); - this.onBlur.emit({ value: event.value, error: this.validationError }); + this.onBlur.emit(event); if (!this.controlled) { this.value = event.value; this.cdRef.detectChanges(); From 32bc1ad37eb22c919a4d03908157adcebb2dc589 Mon Sep 17 00:00:00 2001 From: Jialecl Date: Tue, 25 Jan 2022 16:29:31 +0100 Subject: [PATCH 2/2] deglossing event object --- .../dxc-number-input.component.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts b/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts index b8216b698..c0dbd14cf 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts @@ -215,24 +215,24 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy { )}`; } - handleOnChange(event) { + handleOnChange({value, error}) { this.cdRef.detectChanges(); - this.onChange.emit(event); + this.onChange.emit({value, error}); this.controlled ? (this.dxcInputRef.inputRef.nativeElement.value = this.value) - : (this.value = event.value); + : (this.value = value); } - handleOnBlur(event) { - this.validationError = this.validateOnBlur(); - this.onBlur.emit(event); + handleOnBlur({value, error}) { + this.validationError = this.validation(); + this.onBlur.emit({value, error}); if (!this.controlled) { - this.value = event.value; + this.value = value; this.cdRef.detectChanges(); } } - validateOnBlur() { + validation() { let err; const currentValue = coerceNumberProperty(this.value); if (this.value && this.min && currentValue < this.min) { @@ -244,7 +244,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy { } handleStepMinus() { - this.handleOnBlur({ value: this.value }); + this.handleOnBlur({ value: this.value, error: this.validation() }); let currentValue; if (this.value === null || this.value === undefined) { currentValue = 0; @@ -257,7 +257,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy { } handleStepPlus() { - this.handleOnBlur({ value: this.value }); + this.handleOnBlur({ value: this.value, error: this.validation() }); let currentValue; if (this.value === null || this.value === undefined) { currentValue = 0;