Skip to content

Commit 66c1999

Browse files
committed
Open international selector on PhoneNumberInput if user starts typing
1 parent d65c4b2 commit 66c1999

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
underlying input field is disabled.
77
* Fix #251: In `FileUploadWidget`, accept MIME-type is now checked on the client side before
88
upoading a file.
9-
* Use proper renderer for widget `TelInput` introduced in Django-6.0.
9+
* Fix: Use proper renderer for widget `TelInput` introduced in Django-6.0.
1010
* Fix #256: Set position for widget `PhoneNumberInput` if used with a default country.
11+
* Fix: Open international selector for widget `PhoneNumberInput` if used without a default
12+
country and user starts typing.
1113
* Fix: In `Selectize` widget, when using `filter_by`, an empty filter value is now properly
1214
ignored when loading options lazily.
1315

client/django-formset/PhoneNumber.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,12 @@ class PhoneNumberField {
291291
this.inputElement.value = '+';
292292
} else {
293293
this.inputElement.value = this.asYouType.getNumberValue() ?? '';
294-
if (isFirst && this.defaultCountryCode) {
295-
caretPosition = this.editField.innerText.length;
294+
if (isFirst) {
295+
if (this.defaultCountryCode) {
296+
caretPosition = this.editField.innerText.length;
297+
} else {
298+
this.openInternationalSelector();
299+
}
296300
}
297301
}
298302
this.setCaretPosition(caretPosition);

testapp/forms/phone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PhoneForm(forms.Form):
1515
)
1616
mobile_number = fields.CharField(
1717
label="Mobile Number",
18-
initial='+43 664 1234567',
18+
#initial='+43 664 1234567',
1919
validators=[phone_number_validator],
2020
widget=PhoneNumberInput(attrs={'default-country-code': 'at', 'mobile-only': True}),
2121
)

0 commit comments

Comments
 (0)