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

Enable ESC and clicking background to close full screen dialog #8697

Merged
merged 9 commits into from
Feb 1, 2018
22 changes: 20 additions & 2 deletions _inc/client/components/jetpack-dialogue/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,31 @@ import onKeyDownCallback from 'utils/onkeydown-callback';
import { imagePath } from 'constants/urls';

class JetpackDialogue extends Component {
clickBackground( e ) {
this.props.dismiss( e );
}

// capture the ESC key globally
componentDidMount(){
document.addEventListener('keydown', this.props.dismiss, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these new rules should respect this.props.showDismiss -- there may be instances we don't want to allow dismissal without action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea - fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git push? While you're in there can you apply code standard spacing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

componentWillUnmount(){
document.removeEventListener('keydown', this.props.dismiss, false);
}

// prevent foreground clicks going through to the background
clickForeground( e ) {
e.stopPropagation();
}

render() {
const classes = classNames(
this.props.className,
'jp-dialogue'
);
return (
<div className="jp-dialogue-full__container">
<div className="jp-dialogue-full__container" onClick={this.clickBackground.bind(this)}>
<img src={ imagePath + 'stars-full.svg' } width="60" height="60" alt={ __( 'Stars' ) } className="jp-jumpstart-full__svg-stars" />
<img src={ imagePath + 'jupiter.svg' } width="50" height="100" alt={ __( 'Jupiter' ) } className="jp-jumpstart-full__svg-jupiter" />
{
Expand All @@ -36,7 +54,7 @@ class JetpackDialogue extends Component {
/>
}

<div className={ classes }>
<div className={ classes } onClick={this.clickForeground.bind(this)}>
{ this.props.svg }

<h1 className="jp-dialogue__title">
Expand Down