Skip to content

Commit 620b992

Browse files
4manasamanasatumms2021389
authored
Fixed the issue of country code not being passed in the phone component (#305)
* Fixed the issue of country code not being passed in the phone component * phoone component cleanup --------- Co-authored-by: manasa <manasa.mashetty@in.pega.com> Co-authored-by: tumms2021389 <97188066+tumms2021389@users.noreply.github.com> Co-authored-by: Siva Rama Krishna <sivaramakrishna.tumma@in.pega.com>
1 parent e4ab650 commit 620b992

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
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 & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,11 @@ export class PhoneComponent implements OnInit, OnDestroy {
3838
displayMode$?: string = '';
3939
controlName$: string;
4040
bHasForm$ = true;
41-
componentReference = '';
4241
testId: string;
43-
separateDialCode = false;
44-
afterBlur: boolean;
4542
helperText: string;
4643

4744
fieldControl = new FormControl('', null);
4845

49-
phoneForm = new FormGroup({
50-
phone: new FormControl<string | null>(null)
51-
});
52-
5346
actionsApi: Object;
5447
propName: string;
5548

@@ -151,10 +144,6 @@ export class PhoneComponent implements OnInit, OnDestroy {
151144
this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
152145
}
153146

154-
if (this.bReadonly$) {
155-
this.phoneForm.setValue({ phone: this.value$ });
156-
}
157-
158147
// trigger display of error message with field control
159148
if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
160149
const timer = interval(100).subscribe(() => {
@@ -170,13 +159,13 @@ export class PhoneComponent implements OnInit, OnDestroy {
170159
// 'blur' isn't getting fired
171160
}
172161

173-
fieldOnChange(event: any) {
162+
fieldOnChange() {
174163
const oldVal = this.value$ ?? '';
175-
const isValueChanged = event?.target?.value.toString() !== oldVal.toString();
164+
const newVal = this.formGroup$.controls[this.controlName$].value;
165+
const isValueChanged = newVal?.toString() !== oldVal.toString();
176166

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

0 commit comments

Comments
 (0)