File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -116,9 +116,11 @@ export function inputHandler(event) {
116116 positionFromEnd = target . value . length - positionFromEnd
117117 positionFromEnd = Math . max ( positionFromEnd , config . prefix . length + 1 )
118118 const decimalPosition = target . value . indexOf ( config . decimal )
119- if ( decimalPosition > 0 && ( positionFromEnd - decimalPosition ) <= config . precision ) {
120- // eslint-disable-next-line no-plusplus
121- positionFromEnd ++
119+ const diff = positionFromEnd - decimalPosition
120+ const maxLength = target . value . length - config . suffix . length
121+ const positionAfterDecimal = positionFromEnd + 1
122+ if ( decimalPosition > 0 && diff > 0 && positionAfterDecimal <= maxLength ) {
123+ positionFromEnd = positionAfterDecimal
122124 }
123125 updateCursor ( target , positionFromEnd )
124126
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export default {
3434 // check decimal key and insert to current element
3535 // updated cursor position after format the value
3636 el . onkeydown = ( e ) => {
37- if ( e . key === '.' ) {
37+ if ( e . key === '.' || e . key === config . decimal ) {
3838 e . preventDefault ( )
3939 el . setRangeText ( config . decimal )
4040 el . dispatchEvent ( new Event ( 'input' ) )
You can’t perform that action at this time.
0 commit comments