Skip to content

Commit

Permalink
Fixed #91
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 17, 2017
1 parent e986c4f commit f22a5a5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/components/inputtext/InputText.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,37 @@ export class InputText extends Component {
constructor(props) {
super(props);
this.onInput = this.onInput.bind(this);
this.state = {filled: false};
}

onInput(e) {
if(this.props.onInput) {
this.props.onInput(e);
}

this.updateFilledState(e);
this.updateFilledState(e.target.value);
}

updateFilledState(e) {
let _filled = (e.target.value && e.target.value.length) ? true : false;
this.setState({filled: _filled});
updateFilledState(val) {
if(val && val.length)
this.inputEl.classList.add('ui-state-filled');
else
this.inputEl.classList.remove('ui-state-filled');
}

componentDidMount() {
let _value = this.props.value||this.props.defaultValue,
_filled = (_value && _value.length) ? true : false;
let _value = this.props.value||this.props.defaultValue;

this.setState({filled: _filled});
this.updateFilledState(_value);
}

render() {
var className = classNames('ui-inputtext ui-state-default ui-corner-all ui-widget', this.props.className, {
'ui-state-disabled': this.props.disabled,
'ui-state-filled': this.state.filled
'ui-state-disabled': this.props.disabled
});

let inputProps = Object.assign({}, this.props);
delete inputProps.onInput;

return <input {...inputProps} className={className} onInput={this.onInput}/>;
return <input ref={(el) => this.inputEl = el} {...inputProps} className={className} onInput={this.onInput}/>;
}
}

0 comments on commit f22a5a5

Please sign in to comment.