File tree Expand file tree Collapse file tree 2 files changed +4055
-4469
lines changed
packages/svelte-tel-input/src/lib/components/input Expand file tree Collapse file tree 2 files changed +4055
-4469
lines changed Original file line number Diff line number Diff line change 8888 formattedValue : string ,
8989 initialCursorPosition : number
9090 ) => {
91+ // If cursor was at the end of the original input, keep it at the end of the formatted input
92+ if (initialCursorPosition >= newValue .length ) {
93+ return formattedValue .length ;
94+ }
95+
96+ // For other cursor positions, use the existing logic to map cursor position
9197 let fvIndex = 0 ;
9298 for (let nvIndex = 0 ; nvIndex < initialCursorPosition ; nvIndex ++ ) {
9399 // Since newValue has not been normalized yet, we need to map any non standard digits.
155161 inputValue ,
156162 initialCursorPosition
157163 );
164+
158165 el .selectionStart = newCursorPosition ;
159166 el .selectionEnd = newCursorPosition ;
160167 }
169176 inputValue ,
170177 initialCursorPosition
171178 );
179+
172180 el .selectionStart = newCursorPosition ;
173181 el .selectionEnd = newCursorPosition ;
174182 }
You can’t perform that action at this time.
0 commit comments