Skip to content

Commit 87dbbe1

Browse files
Merge pull request #621 from dxc-technology/numberFix
[Patch] fixing number events behaviour
2 parents 8ed8b86 + 32bc1ad commit 87dbbe1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

projects/dxc-ngx-cdk/src/lib/dxc-number-input/dxc-number-input.component.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,24 +215,24 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
215215
)}`;
216216
}
217217

218-
handleOnChange(event) {
218+
handleOnChange({value, error}) {
219219
this.cdRef.detectChanges();
220-
this.onChange.emit(event);
220+
this.onChange.emit({value, error});
221221
this.controlled
222222
? (this.dxcInputRef.inputRef.nativeElement.value = this.value)
223-
: (this.value = event);
223+
: (this.value = value);
224224
}
225225

226-
handleOnBlur(event) {
227-
this.validationError = this.validateOnBlur();
228-
this.onBlur.emit({ value: event.value, error: this.validationError });
226+
handleOnBlur({value, error}) {
227+
this.validationError = this.validation();
228+
this.onBlur.emit({value, error});
229229
if (!this.controlled) {
230-
this.value = event.value;
230+
this.value = value;
231231
this.cdRef.detectChanges();
232232
}
233233
}
234234

235-
validateOnBlur() {
235+
validation() {
236236
let err;
237237
const currentValue = coerceNumberProperty(this.value);
238238
if (this.value && this.min && currentValue < this.min) {
@@ -244,7 +244,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
244244
}
245245

246246
handleStepMinus() {
247-
this.handleOnBlur({ value: this.value });
247+
this.handleOnBlur({ value: this.value, error: this.validation() });
248248
let currentValue;
249249
if (this.value === null || this.value === undefined) {
250250
currentValue = 0;
@@ -257,7 +257,7 @@ export class DxcNumberInputComponent implements OnInit, OnChanges, OnDestroy {
257257
}
258258

259259
handleStepPlus() {
260-
this.handleOnBlur({ value: this.value });
260+
this.handleOnBlur({ value: this.value, error: this.validation() });
261261
let currentValue;
262262
if (this.value === null || this.value === undefined) {
263263
currentValue = 0;

0 commit comments

Comments
 (0)