Merge pull request #1732 from matrix-org/dbkr/fix_addpresspicker_keys

Fix key bindings in address picker dialog
pull/21833/head
Luke Barnard 2018-02-06 15:26:48 +00:00 committed by GitHub
commit 9625180fbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -37,6 +37,9 @@ export default React.createClass({
// callback to call when Enter is pressed // callback to call when Enter is pressed
onEnterPressed: PropTypes.func, onEnterPressed: PropTypes.func,
// called when a key is pressed
onKeyDown: PropTypes.func,
// CSS class to apply to dialog div // CSS class to apply to dialog div
className: PropTypes.string, className: PropTypes.string,
@ -49,6 +52,9 @@ export default React.createClass({
}, },
_onKeyDown: function(e) { _onKeyDown: function(e) {
if (this.props.onKeyDown) {
this.props.onKeyDown(e);
}
if (e.keyCode === KeyCode.ESCAPE) { if (e.keyCode === KeyCode.ESCAPE) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();