Skip to content

Commit

Permalink
Fix issue with a ghost caret blinking in the end of the input on andr…
Browse files Browse the repository at this point in the history
…oid (text-mask#460)
  • Loading branch information
marcioj authored and lozjackson committed Mar 20, 2017
1 parent 31f9cf9 commit 6e47639
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Expand Up @@ -23,7 +23,8 @@
"dynamicTests": true,
"isVerify": true,
"sinon": true,
"getLineNumber": true
"getLineNumber": true,
"requestAnimationFrame": true
},
"plugins": [
"react",
Expand Down
3 changes: 2 additions & 1 deletion core/src/createTextMaskInputElement.js
Expand Up @@ -8,6 +8,7 @@ const emptyString = ''
const strNone = 'none'
const strObject = 'object'
const isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent)
const defer = typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame : setTimeout

export default function createTextMaskInputElement(config) {
// Anything that we will need to keep between `update` calls, we will store in this `state` object.
Expand Down Expand Up @@ -172,7 +173,7 @@ export default function createTextMaskInputElement(config) {
function safeSetSelection(element, selectionPosition) {
if (document.activeElement === element) {
if (isAndroid) {
setTimeout(() => element.setSelectionRange(selectionPosition, selectionPosition, strNone), 0)
defer(() => element.setSelectionRange(selectionPosition, selectionPosition, strNone), 0)
} else {
element.setSelectionRange(selectionPosition, selectionPosition, strNone)
}
Expand Down

0 comments on commit 6e47639

Please sign in to comment.