Skip to content

Commit e7ad456

Browse files
committed
fix modal backdrop animation changes
1 parent 794ff1a commit e7ad456

File tree

3 files changed

+26
-36
lines changed

3 files changed

+26
-36
lines changed

src/components/Modal/BottomDockedModal/Backdrop/index.web.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,19 @@ function Backdrop({
5454

5555
if (!customBackdrop) {
5656
return (
57-
<PressableWithoutFeedback
58-
accessible
59-
accessibilityLabel={translate('modal.backdropLabel')}
60-
onPress={onBackdropPress}
57+
<Animated.View
58+
style={[styles.modalBackdrop, backdropStyle, style]}
59+
entering={Entering}
60+
exiting={Exiting}
6161
>
62-
<Animated.View
63-
style={[styles.modalBackdrop, backdropStyle, style]}
64-
entering={Entering}
65-
exiting={Exiting}
66-
/>
67-
</PressableWithoutFeedback>
62+
<PressableWithoutFeedback
63+
accessible
64+
accessibilityLabel={translate('modal.backdropLabel')}
65+
onPress={onBackdropPress}
66+
>
67+
<View style={[styles.modalBackdrop, backdropStyle, style]} />
68+
</PressableWithoutFeedback>
69+
</Animated.View>
6870
);
6971
}
7072

src/components/Modal/BottomDockedModal/Container/index.web.tsx

+4-10
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ function Container({style, animationInTiming = 300, animationOutTiming = 300, on
1212
const isInitiated = useSharedValue(false);
1313

1414
useEffect(
15-
() => () => {
16-
setTimeout(onCloseCallBack, animationOutTiming);
17-
},
15+
() => () => onCloseCallBack(),
1816
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
1917
[],
2018
);
@@ -53,16 +51,12 @@ function Container({style, animationInTiming = 300, animationOutTiming = 300, on
5351

5452
return (
5553
<Animated.View
56-
style={[style, styles.modalContainer]}
54+
style={[style, styles.modalContainer, styles.modalAnimatedContainer, animatedStyles]}
55+
exiting={Exiting}
5756
// eslint-disable-next-line react/jsx-props-no-spreading
5857
{...props}
5958
>
60-
<Animated.View
61-
style={[styles.modalAnimatedContainer, animatedStyles]}
62-
exiting={Exiting}
63-
>
64-
{props.children}
65-
</Animated.View>
59+
{props.children}
6660
</Animated.View>
6761
);
6862
}

src/components/Modal/BottomDockedModal/index.tsx

+10-16
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function BottomDockedModal({
3737
...props
3838
}: ModalProps) {
3939
const [isVisibleState, setIsVisibleState] = useState(isVisible);
40-
const [isContainerOpen, setIsContainerOpen] = useState(false);
4140
const [isTransitioning, setIsTransitioning] = useState(false);
4241
const [deviceWidth, setDeviceWidth] = useState(() => Dimensions.get('window').width);
4342
const [deviceHeight, setDeviceHeight] = useState(() => Dimensions.get('window').height);
@@ -104,28 +103,27 @@ function BottomDockedModal({
104103
onModalWillHide();
105104

106105
setIsVisibleState(false);
107-
setIsContainerOpen(false);
108106
},
109107
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
110108
[],
111109
);
112110

113111
useEffect(() => {
114-
if (isVisible && !isContainerOpen && !isTransitioning) {
112+
if (isVisible && !isVisibleState && !isTransitioning) {
115113
handleRef.current = InteractionManager.createInteractionHandle();
116114
onModalWillShow();
117115

118116
setIsVisibleState(true);
119117
setIsTransitioning(true);
120-
} else if (!isVisible && isContainerOpen && !isTransitioning) {
118+
} else if (!isVisible && isVisibleState && !isTransitioning) {
121119
handleRef.current = InteractionManager.createInteractionHandle();
122120
onModalWillHide();
123-
124-
setIsVisibleState(false);
125121
setIsTransitioning(true);
122+
} else if (!isVisible && isVisibleState && isTransitioning) {
123+
setIsVisibleState(false);
126124
}
127125
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
128-
}, [isVisible, isContainerOpen, isTransitioning]);
126+
}, [isVisible, isTransitioning, isVisibleState]);
129127

130128
const backdropStyle: ViewStyle = useMemo(() => {
131129
return {
@@ -137,7 +135,6 @@ function BottomDockedModal({
137135

138136
const onOpenCallBack = useCallback(() => {
139137
setIsTransitioning(false);
140-
setIsContainerOpen(true);
141138
if (handleRef.current) {
142139
InteractionManager.clearInteractionHandle(handleRef.current);
143140
}
@@ -146,7 +143,6 @@ function BottomDockedModal({
146143

147144
const onCloseCallBack = useCallback(() => {
148145
setIsTransitioning(false);
149-
setIsContainerOpen(false);
150146
if (handleRef.current) {
151147
InteractionManager.clearInteractionHandle(handleRef.current);
152148
}
@@ -187,12 +183,10 @@ function BottomDockedModal({
187183
pointerEvents="box-none"
188184
style={[styles.modalBackdrop, styles.modalContainerBox]}
189185
>
190-
{isVisibleState && (
191-
<>
192-
{hasBackdrop && backdropView}
193-
{containerView}
194-
</>
195-
)}
186+
<>
187+
{hasBackdrop && backdropView}
188+
{containerView}
189+
</>
196190
</View>
197191
);
198192
}
@@ -203,7 +197,7 @@ function BottomDockedModal({
203197
transparent
204198
animationType="none"
205199
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
206-
visible={isVisibleState || isTransitioning || isContainerOpen !== isVisibleState}
200+
visible={isVisibleState || isTransitioning}
207201
onRequestClose={onBackButtonPress}
208202
statusBarTranslucent={statusBarTranslucent}
209203
testID={testID}

0 commit comments

Comments
 (0)