Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari: Allow select/copy/paste #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ export class NgxMatIntlTelInputComponent
}

public onInputKeyPress(event: KeyboardEvent): void {
// Allow keyboard shortcuts (Cmd/Ctrl + A/C/V/X)
if (event.metaKey || event.ctrlKey) {
return;
}

const pattern = /[0-9+\- ]/;
if (!pattern.test(event.key)) {
event.preventDefault();
Expand Down Expand Up @@ -361,14 +366,14 @@ export class NgxMatIntlTelInputComponent
return !this.phoneNumber;
}

@HostBinding('class.ngx-floating')
@HostBinding("class.ngx-floating")
get shouldLabelFloat(): boolean {
return this.focused || !this.empty;
}

@Input()
get placeholder(): string {
return this._placeholder || '';
return this._placeholder || "";
}

set placeholder(value: string) {
Expand Down Expand Up @@ -397,17 +402,17 @@ export class NgxMatIntlTelInputComponent
}

setDescribedByIds(ids: string[]) {
this.describedBy = ids.join(' ');
this.describedBy = ids.join(" ");
}

onContainerClick(event: MouseEvent): void {
if ((event.target as Element).tagName.toLowerCase() !== 'input') {
this.elRef.nativeElement.querySelector('input')!.focus();
if ((event.target as Element).tagName.toLowerCase() !== "input") {
this.elRef.nativeElement.querySelector("input")!.focus();
}
}

reset(): void {
this.phoneNumber = '';
this.phoneNumber = "";
this.propagateChange(null);

this._changeDetectorRef.markForCheck();
Expand All @@ -421,20 +426,20 @@ export class NgxMatIntlTelInputComponent

private get formattedPhoneNumber(): string {
if (!this.numberInstance) {
return this.phoneNumber?.toString() || '';
return this.phoneNumber?.toString() || "";
}
switch (this.format) {
case 'national':
case "national":
return this.numberInstance.formatNational();
case 'international':
case "international":
return this.numberInstance.formatInternational();
default:
return this.numberInstance.nationalNumber.toString();
}
}

private formatAsYouTypeIfEnabled(): void {
if (this.format === 'default') {
if (this.format === "default") {
return;
}
const asYouType: AsYouType = new AsYouType(
Expand All @@ -444,7 +449,7 @@ export class NgxMatIntlTelInputComponent
if (
this.phoneNumber
?.toString()
.startsWith(this.previousFormattedNumber || '')
.startsWith(this.previousFormattedNumber || "")
) {
this.phoneNumber = asYouType.input(this.phoneNumber.toString());
}
Expand Down
Loading