mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
#136: add an option to close popup by clicking on overlay
This commit is contained in:
@@ -29,7 +29,7 @@ export class PopupStack extends Component {
|
|||||||
: {...defaultProps, ...popup.props};
|
: {...defaultProps, ...popup.props};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.overlay} key={popup.type + index}>
|
<div className={styles.overlay} key={index} onClick={this.onOverlayClick(popup, props)}>
|
||||||
<div className={styles.popupWrapper}>
|
<div className={styles.popupWrapper}>
|
||||||
<div className={styles.popup}>
|
<div className={styles.popup}>
|
||||||
<Popup {...props} />
|
<Popup {...props} />
|
||||||
@@ -45,6 +45,18 @@ export class PopupStack extends Component {
|
|||||||
onClose(popup) {
|
onClose(popup) {
|
||||||
return this.props.destroy.bind(null, popup);
|
return this.props.destroy.bind(null, popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onOverlayClick(popup, popupProps) {
|
||||||
|
return (event) => {
|
||||||
|
if (event.target !== event.currentTarget || popupProps.disableOverlayClose) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
this.props.destroy(popup);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@@ -76,6 +76,7 @@ export default connect(null, {
|
|||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
dispatch(createPopup(PasswordRequestForm, (props) => ({
|
dispatch(createPopup(PasswordRequestForm, (props) => ({
|
||||||
form,
|
form,
|
||||||
|
disableOverlayClose: true,
|
||||||
onSubmit: () => {
|
onSubmit: () => {
|
||||||
form.beginLoading();
|
form.beginLoading();
|
||||||
sendData()
|
sendData()
|
||||||
|
Reference in New Issue
Block a user