File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
projects/igniteui-angular/src/lib/directives/mask Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ export class MaskParsingService {
91
91
const chars = Array . from ( value ) ;
92
92
let cursor = start ;
93
93
end = Math . min ( end , maskedValue . length ) ;
94
+ let initialMaskedValue = maskedValue ;
94
95
95
96
for ( let i = start ; i < end || ( chars . length && i < maskedValue . length ) ; i ++ ) {
96
97
if ( literalsPositions . indexOf ( i ) !== - 1 ) {
@@ -114,10 +115,21 @@ export class MaskParsingService {
114
115
maskedValue = this . replaceCharAt ( maskedValue , i , char ) ;
115
116
}
116
117
117
- if ( Math . abs ( end - start ) >= 1 ) {
118
- // set cursor to be max between last cursor pos and the calculated `end`
119
- // since on `delete` the cursor should move forward
120
- cursor = Math . max ( cursor , end ) ;
118
+ if ( value . length <= 1 ) {
119
+ let isDelete = false ;
120
+ cursor = start ;
121
+ for ( let i = 0 ; i < literalsPositions . length ; i ++ ) {
122
+ if ( value === '' ) {
123
+ // on `delete` the cursor should move forward
124
+ cursor = Math . max ( cursor , end ) ;
125
+ isDelete = true ;
126
+ } else if ( cursor === literalsPositions [ i ] ) {
127
+ cursor = literalsPositions [ i ] + 1 ;
128
+ }
129
+ }
130
+ if ( ! isDelete && initialMaskedValue !== maskedValue ) {
131
+ cursor ++ ;
132
+ }
121
133
}
122
134
123
135
return { value : maskedValue , end : cursor } ;
You can’t perform that action at this time.
0 commit comments