Skip to content

Commit

Permalink
fix(custom-mask): fixing when remove value from middle of the text.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-hur Santos Ott committed Aug 26, 2017
1 parent 2793cae commit 2fb8e8c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Some types accept options, use it like this: `<TextInputMask type={'money'} opti
* 9 - accept digit.
* A - accept alpha.
* S - accept alphanumeric.
* * - accept all.
* * - accept all, EXCEPT white space.
*/
mask: '999#AAA',

Expand Down Expand Up @@ -404,6 +404,10 @@ var money = MaskService.toMask('money', '123', {


# Changelog
## 1.6.2
* Fixing custom mask when removing value in middle of the text. (thanks to [Aleksandr Kompaniets](https://github.com/Oxyaction))
* KNOW ISSUE: the custom mask is not allowing white spaces temporarily.

## 1.6.1
* Fixing duplicated custom text input component. (thanks to [Pablo](https://github.com/rochapablo))

Expand Down
4 changes: 4 additions & 0 deletions lib/masks/_base.mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ export default class BaseMask {
removeNotNumbers(text) {
return text.replace(/[^0-9]+/g, '');
}

removeWhiteSpaces(text) {
return (text || '').replace(/\s/g,'')
}
}
2 changes: 1 addition & 1 deletion lib/masks/custom.mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class CustomMask extends BaseMask {
let { mask } = settings;
let translation = this.mergeSettings(DEFAULT_TRANSLATION, settings.translation);

var masked = new TinyMask(mask, { translation }).mask(value);
var masked = new TinyMask(mask, { translation }).mask(this.removeWhiteSpaces(value));
return masked;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-masked-text",
"version": "1.6.1",
"version": "1.6.2",
"description": "Text and TextInput with mask for React Native applications",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 2fb8e8c

Please sign in to comment.