1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

esc to close modal

This commit is contained in:
Dick Choi
2016-07-23 15:45:21 +09:00
parent 286739f770
commit 1ff33378e1
3 changed files with 39 additions and 4 deletions

View File

@@ -68,7 +68,9 @@ class InitModal extends React.Component {
newState.legacyStorageExists = true
newState.data = data
}
this.setState(newState)
this.setState(newState, () => {
this.refs.createButton.focus()
})
}
handlePathBrowseButtonClick (e) {
@@ -166,6 +168,12 @@ class InitModal extends React.Component {
})
}
handleKeyDown (e) {
if (e.keyCode === 27) {
this.props.close()
}
}
render () {
if (this.state.isLoading) {
return <div styleName='root--loading'>
@@ -174,7 +182,10 @@ class InitModal extends React.Component {
</div>
}
return (
<div styleName='root'>
<div styleName='root'
tabIndex='-1'
onKeyDown={(e) => this.handleKeyDown(e)}
>
<div styleName='header'>
<div styleName='header-title'>Initialize Storage</div>
@@ -207,6 +218,7 @@ class InitModal extends React.Component {
<div styleName='body-control'>
<button styleName='body-control-createButton'
ref='createButton'
onClick={(e) => this.handleSubmitButtonClick(e)}
disabled={this.state.isSending}
>