File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ export function inputHandler(event) {
133
133
// updated cursor position
134
134
positionFromEnd = Math . max ( positionFromEnd , config . suffix . length )
135
135
positionFromEnd = target . value . length - positionFromEnd
136
- positionFromEnd = Math . max ( positionFromEnd , config . prefix . length + 1 )
136
+ positionFromEnd = Math . max ( positionFromEnd , config . prefix . length )
137
137
updateCursor ( target , positionFromEnd )
138
138
139
139
if ( oldValue !== target . value ) {
Original file line number Diff line number Diff line change @@ -49,6 +49,24 @@ export default {
49
49
el . value . includes ( config . decimal )
50
50
) {
51
51
e . preventDefault ( )
52
+ } else if ( [ 8 ] . includes ( e . keyCode ) ) {
53
+ // check current cursor position is after separator when backspace key down
54
+ const character = el . value . slice ( el . selectionEnd - 1 , el . selectionEnd )
55
+ const replace = el . value . slice ( el . selectionEnd - 2 , el . selectionEnd )
56
+ if ( character === config . separator ) {
57
+ e . preventDefault ( )
58
+
59
+ let positionFromEnd = el . value . length - el . selectionEnd
60
+ // remove separator and before character
61
+ el . value = el . value . replace ( replace , '' )
62
+ // updated cursor position
63
+ positionFromEnd = Math . max ( positionFromEnd , config . suffix . length )
64
+ positionFromEnd = el . value . length - positionFromEnd
65
+ positionFromEnd = Math . max ( positionFromEnd , config . prefix . length )
66
+ core . updateCursor ( el , positionFromEnd )
67
+ // trigger input event
68
+ el . dispatchEvent ( new Event ( 'input' ) )
69
+ }
52
70
}
53
71
}
54
72
You can’t perform that action at this time.
0 commit comments