From 9033a1e5b59e98e2450d23b1d13b18efb40d43e1 Mon Sep 17 00:00:00 2001 From: John White <750350+johnhwhite@users.noreply.github.com> Date: Wed, 22 Jan 2025 08:15:25 -0500 Subject: [PATCH] fix(components/autonumeric): support negativeBracketsTypeOnBlur option (#3049) [AB#3230187](https://dev.azure.com/blackbaud/f565481a-7bc9-4083-95d5-4f953da6d499/_workitems/edit/3230187) --- .../autonumeric/autonumeric.directive.spec.ts | 16 ++++++++++++++++ .../modules/autonumeric/autonumeric.directive.ts | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.spec.ts b/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.spec.ts index a2b7d89815..4222204a5b 100644 --- a/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.spec.ts +++ b/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.spec.ts @@ -211,6 +211,22 @@ describe('Autonumeric directive', () => { expect(formattedValue).toEqual('1,000.00000'); })); + it('should support negativeBracketsTypeOnBlur', fakeAsync(() => { + setOptions({ + currencySymbol: '$', + decimalPlaces: 2, + negativeBracketsTypeOnBlur: '(,)', + }); + + setValue(1000); + + const modelValue = getModelValue(); + const formattedValue = getFormattedValue(); + + expect(modelValue).toEqual(1000); + expect(formattedValue).toEqual('$1,000.00'); + })); + it('should update numeric value on keyup', fakeAsync(() => { detectChangesTick(); diff --git a/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.ts b/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.ts index d2b48af6dc..299e2c95c7 100644 --- a/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.ts +++ b/libs/components/autonumeric/src/lib/modules/autonumeric/autonumeric.directive.ts @@ -149,9 +149,9 @@ export class SkyAutonumericDirective if (typeof value === 'number') { if (this.skyAutonumericFormChangesUnformatted) { - this.#autonumericInstance.setUnformatted(value); + this.#autonumericInstance.setUnformatted(value.toString()); } else { - this.#autonumericInstance.set(value); + this.#autonumericInstance.set(value.toString()); } } else { this.#autonumericInstance.clear();