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 optional scrollOnFocus prop #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
20,804 changes: 20,793 additions & 11 deletions dist/react-select-box.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-select-box.js.map

Large diffs are not rendered by default.

22 changes: 21 additions & 1 deletion dist/react-select-box.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-select-box.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"no-console": 2,
"no-floating-decimal": 2,
"no-self-compare": 2
}
},
"plugins": [
"react"
]
}
6 changes: 4 additions & 2 deletions example/example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var React = require('react')
var ReactDOM = require('react-dom')
var SelectBox = React.createFactory(require('../lib/select-box'))

var div = React.createElement.bind(null,'div')
Expand Down Expand Up @@ -42,7 +43,8 @@ var Example = React.createFactory(React.createClass({displayName: 'Example',
label: "Favorite Colors",
onChange: this.handleMultiChange,
value: this.state.colors,
multiple: true
multiple: true,
scrollOnFocus: false,
},
option({value: 'red'}, 'Red'),
option({value: 'green'}, 'Green'),
Expand All @@ -56,4 +58,4 @@ var Example = React.createFactory(React.createClass({displayName: 'Example',
}
}))

React.render(Example(null), document.body)
ReactDOM.render(Example(null), document.querySelector('#main'))
1 change: 1 addition & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<link rel="stylesheet" href="select-box.css" />
</head>
<body>
<div id="main"></div>
<script src="example.js"></script>
</body>
</html>
7 changes: 4 additions & 3 deletions lib/select-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports = React.createClass({displayName: 'exports',
getDefaultProps: function () {
return {
closeText: 'Close',
clearText: 'Remove selection'
clearText: 'Remove selection',
scrollOnFocus: true
}
},

Expand Down Expand Up @@ -101,7 +102,7 @@ module.exports = React.createClass({displayName: 'exports',
} else {
this.updatePendingValue(val, cb) || this.props.onChange(val)
this.handleClose()
this.refs.button.getDOMNode().focus()
this.refs.button.focus()
}
}.bind(this)
},
Expand Down Expand Up @@ -141,7 +142,7 @@ module.exports = React.createClass({displayName: 'exports',
handleOpen: function (event) {
interceptEvent(event)
this.setState({open: true}, function () {
this.refs.menu.getDOMNode().focus()
this.props.scrollOnFocus ? this.refs.menu.focus() : null
})
},

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@
"devDependencies": {
"browserify": "^5.9.1",
"chai": "^1.9.1",
"eslint": "^3.2.2",
"eslint-plugin-react": "^6.0.0",
"gulp": "^3.8.6",
"gulp-cached": "^1.0.1",
"gulp-connect": "^2.0.6",
"gulp-eslint": "^0.1.8",
"gulp-eslint": "^3.0.1",
"jsx-loader": "^0.13.2",
"karma": "^0.12.21",
"karma-chai": "^0.1.0",
"karma-firefox-launcher": "^0.1.3",
"karma-mocha": "^0.1.6",
"karma-webpack": "^1.2.1",
"mocha": "^1.21.3",
"react": "^0.13.0",
"react": "^15.3.0",
"react-dom": "^15.3.0",
"vinyl-source-stream": "^0.1.1",
"webpack": "^1.3.3-beta1",
"webpack-dev-server": "^1.4.9"
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
entry: "./example/main.js",
entry: "./example/example.js",
output: {
library: 'ReactSelectBox',
libraryTarget: 'umd'
Expand Down