Skip to content

Commit

Permalink
fix for GeekyAnts#627
Browse files Browse the repository at this point in the history
  • Loading branch information
shivrajkumar committed Jun 19, 2017
1 parent 4b08cdc commit e518365
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/basic/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,31 @@ class Item extends Component {
};
}
componentDidMount() {
if (this.inputProps.value) {
this.setState({ isFocused: true });
this.floatUp(-16);
if (this.props.floatingLabel) {
if (this.inputProps.value) {
this.setState({ isFocused: true });
this.floatUp(-16);
}
if (this.inputProps && this.inputProps.getRef) this.inputProps.getRef(this._inputRef);
}
}
componentWillReceiveProps(nextProps) {
const childrenArray = React.Children.toArray(nextProps.children);
let inputProps = {};
input = _.remove(childrenArray, item => {
if (item.type.displayName === 'Styled(Input)') {
inputProps = item.props;
this.inputProps = item.props;
return item;
}
});
if (this.props.floatingLabel) {
if (this.inputProps.value) {
this.setState({ isFocused: true });
this.floatUp(-16);
}
if (this.inputProps && this.inputProps.getRef) this.inputProps.getRef(this._inputRef);
}
if (this.inputProps && this.inputProps.getRef) this.inputProps.getRef(this._inputRef);
}

floatBack() {
Expand All @@ -40,7 +60,7 @@ class Item extends Component {

floatUp(e) {
Animated.timing(this.state.topAnim, {
toValue: e ? e : -22,
toValue: e || -22,
duration: 150,
}).start();
Animated.timing(this.state.opacAnim, {
Expand Down

0 comments on commit e518365

Please sign in to comment.