Skip to content

Commit 7ee75fe

Browse files
author
manasa
committed
Fixed the issue of country code not being passed in the phone component
1 parent 3dee647 commit 7ee75fe

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[preferredCountries]="['us']"
1212
[enablePlaceholder]="true"
1313
[enableSearch]="true"
14-
(change)="fieldOnChange($event)"
14+
(change)="fieldOnChange()"
1515
(blur)="fieldOnBlur()"
1616
>
1717
</ngx-mat-intl-tel-input>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,13 @@ export class PhoneComponent implements OnInit, OnDestroy {
170170
// 'blur' isn't getting fired
171171
}
172172

173-
fieldOnChange(event: any) {
173+
fieldOnChange() {
174174
const oldVal = this.value$ ?? '';
175-
const isValueChanged = event?.target?.value.toString() !== oldVal.toString();
175+
const newVal = this.formGroup$.controls[this.controlName$].value;
176+
const isValueChanged = newVal?.toString() !== oldVal.toString();
176177

177-
if (isValueChanged) {
178-
const value = event?.target?.value || event?.value || '';
178+
if (isValueChanged && newVal) {
179+
const value = this.formGroup$.controls[this.controlName$].value;
179180
this.afterBlur = true;
180181
handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
181182
}

0 commit comments

Comments
 (0)