react-input-mask
Advanced tools
Comparing version 0.5.9 to 0.5.10
@@ -458,2 +458,3 @@ // https://github.com/sanniassin/react-input-mask | ||
var caretPos = this.getCaretPos(); | ||
var selection = this.getSelection(); | ||
var value = this.state.value; | ||
@@ -472,2 +473,3 @@ var mask = this.mask; | ||
if (editablePos !== null && this.isAllowedChar(key, editablePos)) { | ||
value = this.clearRange(value, selection.start, selection.length); | ||
value = this.insertRawSubstr(value, key, editablePos); | ||
@@ -474,0 +476,0 @@ caretPos = editablePos + 1; |
@@ -454,2 +454,3 @@ // https://github.com/sanniassin/react-input-mask | ||
var caretPos = this.getCaretPos(); | ||
var selection = this.getSelection(); | ||
var { value } = this.state; | ||
@@ -467,2 +468,3 @@ var { mask, maskChar } = this; | ||
if (editablePos !== null && this.isAllowedChar(key, editablePos)) { | ||
value = this.clearRange(value, selection.start, selection.length); | ||
value = this.insertRawSubstr(value, key, editablePos); | ||
@@ -469,0 +471,0 @@ caretPos = editablePos + 1; |
{ | ||
"name": "react-input-mask", | ||
"description": "Masked input component for React", | ||
"version": "0.5.9", | ||
"version": "0.5.10", | ||
"homepage": "https://github.com/sanniassin/react-input-mask", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -30,3 +30,3 @@ # react-input-mask | ||
render: function() { | ||
return <InputElement {...this.props} mask="+4\\9 99 999 99" maskChar=" "/>; | ||
return <InputElement {...this.props} mask="+4\9 99 999 99" maskChar=" "/>; | ||
} | ||
@@ -33,0 +33,0 @@ }); |
@@ -236,5 +236,13 @@ import React from 'react'; | ||
TestUtils.Simulate.keyPress(inputNode, { key: '6' }); | ||
expect(inputNode.value).toEqual('+7 (611) 112 34 56'); | ||
input.setSelection(4, 3); | ||
TestUtils.Simulate.keyPress(inputNode, { key: '0' }); | ||
expect(inputNode.value).toEqual('+7 (012) 345 6'); | ||
input.setCaretPos(14) | ||
TestUtils.Simulate.keyPress(inputNode, { key: '7' }); | ||
TestUtils.Simulate.keyPress(inputNode, { key: '8' }); | ||
TestUtils.Simulate.keyPress(inputNode, { key: '9' }); | ||
TestUtils.Simulate.keyPress(inputNode, { key: '4' }); | ||
expect(inputNode.value).toEqual('+7 (012) 345 67 89'); | ||
inputNode.value = '+7 ('; | ||
@@ -241,0 +249,0 @@ input.setCaretPos(4); |
67116
1690