Skip to content

Commit 6fb8569

Browse files
4manasamashm
andauthored
Fixed the percentage issue (#241)
* Fixed the percentage issue --------- Co-authored-by: mashm <[email protected]>
1 parent 7d6fbb9 commit 6fb8569

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/angular-sdk-components/src/lib/_components/field/percentage/percentage.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
(change)="fieldOnChange($event)"
3030
(blur)="fieldOnBlur($event)"
3131
[readonly]="bReadonly$"
32+
[value]="value$"
3233
/>
3334
<mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
3435
</mat-form-field>

packages/angular-sdk-components/src/lib/_components/field/percentage/percentage.component.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,8 @@ export class PercentageComponent implements OnInit, OnDestroy {
113113
this.label$ = this.configProps$.label;
114114
this.displayMode$ = this.configProps$.displayMode;
115115
this.inputMode = NgxCurrencyInputMode.Natural;
116-
let nValue: any = this.configProps$.value;
116+
const nValue: any = this.configProps$.value;
117117
if (nValue) {
118-
if (typeof nValue === 'string') {
119-
nValue = parseInt(nValue, 10);
120-
}
121118
this.value$ = nValue;
122119
}
123120
this.helperText = this.configProps$.helperText;
@@ -178,11 +175,11 @@ export class PercentageComponent implements OnInit, OnDestroy {
178175
const propName = this.pConn$?.getStateProps()?.value;
179176
let value = event?.target?.value;
180177
value = value ? value.replace(/%/g, '') : '';
181-
if (this.currSep === ',') {
182-
value = value.replace(/,/g, '');
183-
} else {
178+
if (this.currSep === '.') {
184179
value = value?.replace(/\./g, '');
185180
value = value?.replace(/,/g, '.');
181+
} else {
182+
value = value.replace(/,/g, '');
186183
}
187184
handleEvent(actionsApi, 'changeNblur', propName, value);
188185
}

0 commit comments

Comments
 (0)