Skip to content

[CP Staging] Revert "fix modal backdrop animation changes" #62190

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/components/Modal/BottomDockedModal/Backdrop/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,17 @@ function Backdrop({

if (!customBackdrop) {
return (
<Animated.View
style={[styles.modalBackdrop, backdropStyle, style]}
entering={Entering}
exiting={Exiting}
<PressableWithoutFeedback
accessible
accessibilityLabel={translate('modal.backdropLabel')}
onPress={onBackdropPress}
>
<PressableWithoutFeedback
accessible
accessibilityLabel={translate('modal.backdropLabel')}
onPress={onBackdropPress}
>
<View style={[styles.modalBackdrop, backdropStyle, style]} />
</PressableWithoutFeedback>
</Animated.View>
<Animated.View
style={[styles.modalBackdrop, backdropStyle, style]}
entering={Entering}
exiting={Exiting}
/>
</PressableWithoutFeedback>
);
}

Expand Down
14 changes: 10 additions & 4 deletions src/components/Modal/BottomDockedModal/Container/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function Container({style, animationInTiming = 300, animationOutTiming = 300, on
const isInitiated = useSharedValue(false);

useEffect(
() => () => onCloseCallBack(),
() => () => {
setTimeout(onCloseCallBack, animationOutTiming);
},
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[],
);
Expand Down Expand Up @@ -51,12 +53,16 @@ function Container({style, animationInTiming = 300, animationOutTiming = 300, on

return (
<Animated.View
style={[style, styles.modalContainer, styles.modalAnimatedContainer, animatedStyles]}
exiting={Exiting}
style={[style, styles.modalContainer]}
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
>
{props.children}
<Animated.View
style={[styles.modalAnimatedContainer, animatedStyles]}
exiting={Exiting}
>
{props.children}
</Animated.View>
</Animated.View>
);
}
Expand Down
26 changes: 16 additions & 10 deletions src/components/Modal/BottomDockedModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function BottomDockedModal({
...props
}: ModalProps) {
const [isVisibleState, setIsVisibleState] = useState(isVisible);
const [isContainerOpen, setIsContainerOpen] = useState(false);
const [isTransitioning, setIsTransitioning] = useState(false);
const [deviceWidth, setDeviceWidth] = useState(() => Dimensions.get('window').width);
const [deviceHeight, setDeviceHeight] = useState(() => Dimensions.get('window').height);
Expand Down Expand Up @@ -106,27 +107,28 @@ function BottomDockedModal({
}

setIsVisibleState(false);
setIsContainerOpen(false);
},
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[],
);

useEffect(() => {
if (isVisible && !isVisibleState && !isTransitioning) {
if (isVisible && !isContainerOpen && !isTransitioning) {
handleRef.current = InteractionManager.createInteractionHandle();
onModalWillShow();

setIsVisibleState(true);
setIsTransitioning(true);
} else if (!isVisible && isVisibleState && !isTransitioning) {
} else if (!isVisible && isContainerOpen && !isTransitioning) {
handleRef.current = InteractionManager.createInteractionHandle();
onModalWillHide();
setIsTransitioning(true);
} else if (!isVisible && isVisibleState && isTransitioning) {

setIsVisibleState(false);
setIsTransitioning(true);
}
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isVisible, isTransitioning, isVisibleState]);
}, [isVisible, isContainerOpen, isTransitioning]);

const backdropStyle: ViewStyle = useMemo(() => {
return {
Expand All @@ -138,6 +140,7 @@ function BottomDockedModal({

const onOpenCallBack = useCallback(() => {
setIsTransitioning(false);
setIsContainerOpen(true);
if (handleRef.current) {
InteractionManager.clearInteractionHandle(handleRef.current);
}
Expand All @@ -146,6 +149,7 @@ function BottomDockedModal({

const onCloseCallBack = useCallback(() => {
setIsTransitioning(false);
setIsContainerOpen(false);
if (handleRef.current) {
InteractionManager.clearInteractionHandle(handleRef.current);
}
Expand Down Expand Up @@ -186,10 +190,12 @@ function BottomDockedModal({
pointerEvents="box-none"
style={[styles.modalBackdrop, styles.modalContainerBox]}
>
<>
{hasBackdrop && backdropView}
{containerView}
</>
{isVisibleState && (
<>
{hasBackdrop && backdropView}
{containerView}
</>
)}
</View>
);
}
Expand All @@ -200,7 +206,7 @@ function BottomDockedModal({
transparent
animationType="none"
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
visible={isVisibleState || isTransitioning}
visible={isVisibleState || isTransitioning || isContainerOpen !== isVisibleState}
onRequestClose={onBackButtonPress}
statusBarTranslucent={statusBarTranslucent}
testID={testID}
Expand Down
Loading