Skip to content

Commit

Permalink
Enable examplePlaceholder without prefill to enable autocomplete comp…
Browse files Browse the repository at this point in the history
…atibility (#774)

* Update PhoneNumberTextField.swift

* Update PhoneNumberTextField.swift
  • Loading branch information
johnfrancmartin authored Aug 7, 2024
1 parent 2a3f4a5 commit 66a792a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PhoneNumberKit/UI/PhoneNumberTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ open class PhoneNumberTextField: UITextField, UITextFieldDelegate {
}
}

public var withPrefixPrefill: Bool = true

public var withFlag: Bool = false {
didSet {
leftView = self.withFlag ? self.flagButton : nil
Expand Down Expand Up @@ -497,7 +499,7 @@ open class PhoneNumberTextField: UITextField, UITextFieldDelegate {
}

open func textFieldDidBeginEditing(_ textField: UITextField) {
if self.withExamplePlaceholder, self.withPrefix, let countryCode = phoneNumberKit.countryCode(for: currentRegion)?.description, (text ?? "").isEmpty {
if self.withExamplePlaceholder, self.withPrefixPrefill, self.withPrefix, let countryCode = phoneNumberKit.countryCode(for: currentRegion)?.description, (text ?? "").isEmpty {
text = "+" + countryCode + " "
}
self._delegate?.textFieldDidBeginEditing?(textField)
Expand Down

0 comments on commit 66a792a

Please sign in to comment.