Skip to content

Commit

Permalink
fix(issue 20): removing default value to allow placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-hur Santos Ott committed May 9, 2017
1 parent 6013964 commit f81e083
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
12 changes: 11 additions & 1 deletion lib/base-text-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
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.3.3",
"version": "1.3.4",
"description": "Text and TextInput with mask for React Native applications",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit f81e083

Please sign in to comment.