File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -280,12 +280,21 @@ class PhoneNumberField {
280280
281281 private updateInputField ( phoneNumber : string ) {
282282 let caretPosition = this . getCaretPosition ( ) ;
283+ let isFirst = false ;
283284 if ( this . editField . innerText . length === caretPosition ) {
285+ isFirst = caretPosition === 1 ;
284286 ++ caretPosition ;
285287 }
286288 this . asYouType . reset ( ) ;
287289 this . asYouType . input ( phoneNumber ) ;
288- this . inputElement . value = this . asYouType . getChars ( ) === '+' ? '+' : this . asYouType . getNumberValue ( ) ?? '' ;
290+ if ( this . asYouType . getChars ( ) === '+' ) {
291+ this . inputElement . value = '+' ;
292+ } else {
293+ this . inputElement . value = this . asYouType . getNumberValue ( ) ?? '' ;
294+ if ( isFirst && this . defaultCountryCode ) {
295+ caretPosition = this . editField . innerText . length ;
296+ }
297+ }
289298 this . setCaretPosition ( caretPosition ) ;
290299 this . inputElement . dispatchEvent ( new Event ( 'input' ) ) ;
291300 }
You can’t perform that action at this time.
0 commit comments