Skip to content

Commit

Permalink
fix(modal): backdrop click
Browse files Browse the repository at this point in the history
  • Loading branch information
jigsawye committed Mar 28, 2019
1 parent bcda7af commit 7da7e04
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 63 deletions.
20 changes: 11 additions & 9 deletions packages/tailor-ui/src/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import useKeydown, { ESC_KEY_CODE } from '../utils/useKeydown';
type Size = 'md' | 'lg';

const ModalWrapper = styled.div`
display: flex;
position: fixed;
z-index: 10001;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
`;

const AnimatedModalWrapper = animated(ModalWrapper);
Expand All @@ -32,6 +29,8 @@ const ModalContent = styled(tag.div)<{ type: Size }>`
background-color: #fff;
`;

const AnimatedModalContent = animated(ModalContent);

export interface BaseModalProps {
onCancel: () => void;
size?: Size;
Expand Down Expand Up @@ -83,10 +82,13 @@ const BaseModal: FunctionComponent<BaseModalProps> = ({
{transitions.map(
({ item, key, props }) =>
item && (
<AnimatedModalWrapper key={key} style={props}>
<ModalContent size={size} {...otherProps}>
<AnimatedModalWrapper
key={key}
style={{ pointerEvents: props.pointerEvents }}
>
<AnimatedModalContent size={size} style={props} {...otherProps}>
{children}
</ModalContent>
</AnimatedModalContent>
</AnimatedModalWrapper>
)
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,13 @@ exports[`Modal should render correctly 1`] = `
}
.c1 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
position: fixed;
z-index: 10001;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.c2 {
Expand Down Expand Up @@ -320,10 +308,10 @@ exports[`Modal should render correctly 1`] = `
/>
<div
class="c1"
style="opacity: 0; transform: scale(0.9);"
>
<div
class="c2"
style="opacity: 0; transform: scale(0.9);"
>
<div
class="c3"
Expand Down Expand Up @@ -485,25 +473,13 @@ exports[`Modal should render correctly with lg size 1`] = `
}
.c0 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
position: fixed;
z-index: 10001;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.c1 {
Expand Down Expand Up @@ -691,10 +667,10 @@ exports[`Modal should render correctly with lg size 1`] = `
<div
class="c0"
style="opacity: 0; transform: scale(0.9);"
>
<div
class="c1"
style="opacity: 0; transform: scale(0.9);"
>
<div
class="c2"
Expand Down Expand Up @@ -879,25 +855,13 @@ exports[`Modal should render with props closable 1`] = `
}
.c0 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
position: fixed;
z-index: 10001;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.c1 {
Expand Down Expand Up @@ -1183,10 +1147,10 @@ exports[`Modal should render with props closable 1`] = `
<div
class="c0"
style="opacity: 0; transform: scale(0.9);"
>
<div
class="c1"
style="opacity: 0; transform: scale(0.9);"
>
<div
class="c2"
Expand Down

0 comments on commit 7da7e04

Please sign in to comment.