MojtabaHs / iPhoneNumberField

Elegant SwiftUI phone number textField.
MIT License
542 stars 90 forks source link

(310) Area code in US resets phone entry #106

Closed shaibruhis closed 1 month ago

shaibruhis commented 2 months ago

I have used iPhoneNumberField like shown below:

iPhoneNumberField("(000) 000-0000", text: $phoneNumber) { phoneNumberTextField in
    phoneNumberTextField.keyboardType = .numberPad
}
.font(.systemFont(ofSize: 24))
.flagSelectable(false)
.flagHidden(false)
.defaultRegion("US")
.maximumDigits(10)
.formatted(false) // This makes phoneNumber is either valid or "".
.prefixHidden(false)
.clearsOnEditingBegan(false)
.clearsOnInsert(false)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding()
.disabled(actionInProgress)
.focused($phoneNumberIsFocused)
.onAppear {
    phoneNumberIsFocused = true
}
.padding(.horizontal, 72)

It has been working well for my signups but today I had someone from Los Angeles with a (310) area code. For some reason the textfield resets itself to 0 after the 7th number is inputted as can be seen in video below. I tried with a number of different area codes and couldn't reproduce with any other area code except (310).

https://github.com/user-attachments/assets/bd028d9f-e8c2-433c-8180-c699a1eb54af

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 14 days since being marked as stale.