Skip to content

Commit

Permalink
fix(Modal): prevent close on click content
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxuoz committed Sep 27, 2019
1 parent d010f1c commit 3e1ebf8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/Dialog/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const Dialog = ({
args={ args }
shouldCloseOnOverlayClick={ shouldCloseOnOverlayClick }
shouldCloseOnEscPress={ shouldCloseOnEscPress }
stretch={ stretch }
>
{
({ args, onClose }) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/Dialog.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const [DialogTag, themeDialog] = createThemeTag('dialog', {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
margin: '40px 0',
maxHeight: 'calc(100vh - 80px)',
},
modifiers: {
stretch: {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Modal extends PureComponent<ModalProps, ModalState> {
}
};

onModalMouseDown = (event) => {
event.stopPropagation();
};

render() {
const { children, isOpen, ...rest } = this.props;

Expand All @@ -78,7 +82,7 @@ class Modal extends PureComponent<ModalProps, ModalState> {
<ModalTag
modifiers={ rest }
tagName="div"
onMouseDown={ this.onOverlayMouseDown }
onMouseDown={ this.onModalMouseDown }
>
{ typeof children === 'function' ? children(rest) : children }
</ModalTag>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Modal/Modal.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ const [OverlayTag, themeOverlay] = createThemeTag(`${name}Overlay`, ({ Z_INDEX }

const [ModalTag, themeModal] = createThemeTag(name, {
root: {
height: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
},
modifiers: {
stretch: {
height: '100%',
},
},
});

const theme = {
Expand Down

0 comments on commit 3e1ebf8

Please sign in to comment.