From f81e083d227e740b52d8e55bc64f4a47ee0e9bc9 Mon Sep 17 00:00:00 2001 From: Ben-hur Santos Ott Date: Tue, 9 May 2017 09:53:20 -0300 Subject: [PATCH] fix(issue 20): removing default value to allow placeholders --- README.md | 4 ++++ lib/base-text-component.js | 12 +++++++++++- package.json | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a98ec58..9c30fffd 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,10 @@ var money = MaskService.toMask('money', '123', { # Changelog +## 1.3.4 +* Remove default value from mask to allow placeholder on text-input (thanks to [Cuong Hoang](https://github.com/cuonghv91)). + * Please, caution. This can cause some runtime breaking if you update to this version. + ## 1.3.3 * Update dependencies (thanks to [Vlad-Zhukov](https://github.com/Vlad-Zhukov)) diff --git a/lib/base-text-component.js b/lib/base-text-component.js index a9242497..dee18f09 100644 --- a/lib/base-text-component.js +++ b/lib/base-text-component.js @@ -74,12 +74,22 @@ export default class BaseTextComponent extends Component { self._resolveMaskHandler(); } + let value = self._getDefaultMaskedValue(props.value); + self.setState({ - value: self._getMaskedValue(props.value) + value: value }); }); } + _getDefaultMaskedValue(value) { + if (this._getDefaultValue(value) === '') { + return '' + } + + return this._getMaskedValue(value) + } + _getMaskedValue(value) { return this._maskHandler.getValue( this._getDefaultValue(value), diff --git a/package.json b/package.json index 6626defc..2db7a85e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-masked-text", - "version": "1.3.3", + "version": "1.3.4", "description": "Text and TextInput with mask for React Native applications", "main": "index.js", "scripts": {