Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the autoFocus attribute #101

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion example/src/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var App = React.createClass({
};
return (
<div>
<Codemirror ref="editor" value={this.state.code} onChange={this.updateCode} options={options} interact={this.interact} />
<Codemirror ref="editor" value={this.state.code} onChange={this.updateCode} options={options} interact={this.interact} autoFocus={true} />
<div style={{ marginTop: 10 }}>
<select onChange={this.changeMode} value={this.state.mode}>
<option value="markdown">Markdown</option>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"lodash.debounce": "^4.0.8"
},
"devDependencies": {
"cross-env": "^4.0.0",
"gulp": "^3.9.1",
"happiness": "^7.1.2",
"react": "^15.3.1",
Expand All @@ -33,7 +34,7 @@
"react": "global:React"
},
"scripts": {
"build": "gulp clean && NODE_ENV=production gulp build",
"build": "gulp clean && cross-env NODE_ENV=production gulp build",
"bump": "gulp bump",
"bump:minor": "gulp bump:minor",
"bump:major": "gulp bump:major",
Expand Down
3 changes: 2 additions & 1 deletion src/Codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const CodeMirror = React.createClass({
path: React.PropTypes.string,
value: React.PropTypes.string,
preserveScrollPosition: React.PropTypes.bool,
autoFocus: React.PropTypes.bool,
},
getDefaultProps () {
return {
Expand Down Expand Up @@ -102,7 +103,7 @@ const CodeMirror = React.createClass({
);
return (
<div className={editorClassName}>
<textarea ref="textarea" name={this.props.path} defaultValue={this.props.value} autoComplete="off" />
<textarea ref="textarea" name={this.props.path} defaultValue={this.props.value} autoComplete="off" autoFocus={this.props.autoFocus} />
</div>
);
},
Expand Down