Skip to content

Commit

Permalink
fix(InputMasked): fix manual range selection
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Nov 16, 2021
1 parent 05cddbd commit a2a1a98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ export const correctCaretPosition = (element, maskParams) => {

if (suffix || prefix) {
const start = element.selectionStart
const end = element.selectionEnd

if (start !== end) {
return // stop here
}

const suffixStart = element.value.indexOf(suffix)
const suffixEnd = suffixStart + suffix?.length
let pos = undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ describe('InputMasked component', () => {
target: {
value,
selectionStart: value.indexOf('kr'), // set it where the mask starts
selectionEnd: value.indexOf('kr'), // set it where the mask starts
setSelectionRange,
},
})
Expand Down

0 comments on commit a2a1a98

Please sign in to comment.