@@ -47,10 +47,6 @@ export function getInputElement(el) {
4747 * @param {Number } position
4848 */
4949export function updateCursor ( el , position ) {
50- const config = el [ CONFIG_KEY ] && el [ CONFIG_KEY ] . config
51- position = Math . max ( position , config . suffix . length )
52- position = el . value . length - position
53- position = Math . max ( position , config . prefix . length + 1 )
5450 const setSelectionRange = ( ) => { el . setSelectionRange ( position , position ) }
5551 if ( el === document . activeElement ) {
5652 setSelectionRange ( )
@@ -111,10 +107,14 @@ export function inputHandler(event) {
111107 // we can stop propagation of this native event
112108 event . stopPropagation ( )
113109
114- const positionFromEnd = target . value . length - target . selectionEnd
115- const { oldValue } = target [ CONFIG_KEY ]
110+ let positionFromEnd = target . value . length - target . selectionEnd
111+ const { oldValue, config } = target [ CONFIG_KEY ]
116112
117113 updateValue ( target , null , { emit : false } , event )
114+ // updated cursor position
115+ positionFromEnd = Math . max ( positionFromEnd , config . suffix . length )
116+ positionFromEnd = target . value . length - positionFromEnd
117+ positionFromEnd = Math . max ( positionFromEnd , config . prefix . length + 1 )
118118 updateCursor ( target , positionFromEnd )
119119
120120 if ( oldValue !== target . value ) {
0 commit comments