Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions dist/editable.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions examples/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export default class App extends Component {
title="Please select city"
placement="right"
showButtons={true}
ignoreDefault={false}
options={[
{value : 1, text: "Mumbai"},
{value : 2, text: "Pune"},
Expand Down Expand Up @@ -451,6 +452,7 @@ export default class App extends Component {
dataType="select"
name={"cityInline"}
value={1}
ignoreDefault={false}
title="Please select city"
options={[
{value : 1, text: "Mumbai"},
Expand Down
7 changes: 5 additions & 2 deletions libs/js/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default class Select extends Component {
}
setInitialOptions = () => {
const options = this.props.options;
options.unshift({value : "select","text" : "select"});
if(!this.props.ignoreDefault) {
options.unshift({value : "select","text" : "select"});
}
return options;
}
getValue = () =>{
Expand Down Expand Up @@ -77,5 +79,6 @@ export default class Select extends Component {
}

Select.defaultProps = {
placeholder : "Enter text"
placeholder : "Enter text",
ignoreDefault : false
};
13 changes: 11 additions & 2 deletions libs/js/Text.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import {
FormControl,
HelpBlock
} from 'react-bootstrap';
import ReactDOM from 'react-dom';

export default class Text extends Component {
constructor(props){
super(props);
this.state = {
value : props.value,
};
this.textField = React.createRef();
}
componentDidMount() {
const node = ReactDOM.findDOMNode(this.textField);
node.focus();
node.select();
}
getValue = () =>{
return this.state.value;
Expand All @@ -35,15 +43,16 @@ export default class Text extends Component {
render(){
return (
<FormGroup controlId="formBasicText" validationState={this.props.validation.type} key={"FormGroup"+this.props.name}>
<FormControl
<FormControl autoFocus
key={"form-control"+this.props.name}
type="text"
placeholder={this.props.placeholder}
bsSize="sm"
value={this.state.value || ''}
onChange={this.setValue.bind(this)}
onBlur={this.onBlur.bind(this)}
onKeyDown={this.handleKeyDown.bind(this)}
onKeyDown={this.handleKeyDown.bind(this)}
inputRef={ref => { this.textField = ref; }}
/>
<HelpBlock key={"HelpBlock"+this.props.name}>{this.props.validation.msg}</HelpBlock>
</FormGroup>
Expand Down
10 changes: 9 additions & 1 deletion libs/js/Textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ import {
FormControl,
HelpBlock
} from 'react-bootstrap';
import ReactDOM from 'react-dom';

export default class Textarea extends Component {
constructor(props){
super(props);
this.state = {
value : props.value,
};
this.textAreaField = React.createRef();
}
componentDidMount() {
const node = ReactDOM.findDOMNode(this.textAreaField);
node.focus();
node.select();
}
getValue = () =>{
return this.state.value;
Expand All @@ -36,7 +43,7 @@ export default class Textarea extends Component {
render(){
return (
<FormGroup controlId="formBasicTextarea" validationState={this.props.validation.type}>
<FormControl
<FormControl autoFocus
style={{height: '200px'}}
componentClass="textarea"
bsSize="sm"
Expand All @@ -45,6 +52,7 @@ export default class Textarea extends Component {
onChange={this.setValue.bind(this)}
onBlur={this.onBlur.bind(this)}
onKeyDown={this.handleKeyDown.bind(this)}
inputRef={ref => { this.textAreaField = ref; }}
/>
<HelpBlock>{this.props.validation.msg}</HelpBlock>
</FormGroup>
Expand Down