(feat) renamed to onEscKeyDown and fixed linting errors
parent
04c7b04ec6
commit
db752d2266
|
@ -21,7 +21,7 @@ const Dialog = (props) => {
|
|||
onMouseDown={props.onOverlayMouseDown}
|
||||
onMouseUp={props.onOverlayMouseUp}
|
||||
onMouseMove={props.onOverlayMouseMove}
|
||||
onEscKeyDown={props.onOverlayEscKeyDown}
|
||||
onEscKeyDown={props.onEscKeyDown}
|
||||
>
|
||||
<div data-react-toolbox='dialog' className={className}>
|
||||
<section role='body' className={style.body}>
|
||||
|
@ -41,8 +41,8 @@ Dialog.propTypes = {
|
|||
active: React.PropTypes.bool,
|
||||
children: React.PropTypes.node,
|
||||
className: React.PropTypes.string,
|
||||
onEscKeyDown: React.PropTypes.func,
|
||||
onOverlayClick: React.PropTypes.func,
|
||||
onOverlayEscKeyDown: React.PropTypes.func,
|
||||
onOverlayMouseDown: React.PropTypes.func,
|
||||
onOverlayMouseMove: React.PropTypes.func,
|
||||
onOverlayMouseUp: React.PropTypes.func,
|
||||
|
|
|
@ -44,6 +44,6 @@ class DialogTest extends React.Component {
|
|||
| `onOverlayMouseDown` | `Function` | | Callback called when the mouse button is pressed on the overlay. |
|
||||
| `onOverlayMouseUp` | `Function` | | Callback called when the mouse button is released over the overlay. |
|
||||
| `onOverlayMouseMove` | `Function` | | Callback called when the mouse is moving over the overlay. |
|
||||
| `onOverlayEscKeyDown` | `Function` | | Callback called when the ESC is pressed with the overlay active. |
|
||||
| `onEscKeyDown` | `Function` | | Callback called when the ESC is pressed with the overlay active. |
|
||||
| `title` | `String` | | The text string to use as standar title of the dialog.|
|
||||
| `type` | `String` | `normal` | Used to determine the size of the dialog. It can be `small`, `normal` or `large`. |
|
||||
|
|
|
@ -39,13 +39,13 @@ class Overlay extends React.Component {
|
|||
ReactDOM.unmountComponentAtNode(this.node);
|
||||
this.app.removeChild(this.node);
|
||||
if (this.escKeyListener) {
|
||||
document.body.removeEventListener('keydown', this.handleEscKey)
|
||||
document.body.removeEventListener('keydown', this.handleEscKey);
|
||||
this.escKeyListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
handleEscKey (e) {
|
||||
if (this.props.active && this.props.onEscKeyDown && e.which == 27) {
|
||||
if (this.props.active && this.props.onEscKeyDown && e.which === 27) {
|
||||
this.props.onEscKeyDown(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class DialogTest extends React.Component {
|
|||
active={this.state.active}
|
||||
title="Use Google's location service?"
|
||||
onOverlayClick={this.handleToggle}
|
||||
onOverlayEscKeyDown={this.handleToggle}
|
||||
onEscKeyDown={this.handleToggle}
|
||||
>
|
||||
<p>Let Google help apps <strong>determine location</strong>. This means sending anonymous location data to Google, even when no apps are running.</p>
|
||||
<DialogChild />
|
||||
|
|
Loading…
Reference in New Issue