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
fix: Check cardStyleInterpolator name to allow for custom animation as well #11209
fix: Check cardStyleInterpolator name to allow for custom animation as well #11209
Conversation
Hey drager! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines. |
✅ Deploy Preview for react-navigation-example ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR
Codecov ReportBase: 74.09% // Head: 74.09% // No change to project coverage 👍
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #11209 +/- ##
=======================================
Coverage 74.09% 74.09%
=======================================
Files 176 176
Lines 5598 5598
Branches 2193 2193
=======================================
Hits 4148 4148
Misses 1401 1401
Partials 49 49
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Please fix the lint errors so that this can be merged |
Head branch was pushed to by a user without write access
Hey @drager! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines. |
7963ea0
to
5545451
Compare
Done! |
5545451
to
765564a
Compare
…s well (#11209) We got a custom `cardStyleInterpolator` in our app that actually calls [forModalPresentationIOS](https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx#L93) but we add some own customizations to it. This worked fine in `v5` of react-navigation, and started to act weird after the upgrade to `v6`, the screen under the modal was displayed right until the animation was finished, then the screen under disappeared, which is unintended. This PR just checks for the name instead. Making it do the same as this check: https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/views/Stack/Card.tsx#L580 and will allow for custom cardStyleInterpolators. This can be reproduced by creating your own cardStyleIntepolator and then call `forModalPresentationIOS`: ```ts import type {StackCardInterpolationProps} from "@react-navigation/stack"; import {CardStyleInterpolators} from "@react-navigation/stack"; export const forModalPresentationIOS = ({ index, current, next, inverted, layouts, insets, ...rest }: StackCardInterpolationProps) => { const defaultAnimations = CardStyleInterpolators.forModalPresentationIOS({ index, current, next, inverted, layouts, insets, ...rest, }); return defaultAnimations }; const ModalStack = createStackNavigator<ModalStackParamList>(); export function ModalNavigator() { return ( <ModalStack.Navigator> <ModalStack.Screen name='Modal' component={() => <View />} options={{ gestureEnabled: true, gestureDirection: "vertical", cardOverlayEnabled: true, cardStyleInterpolator: forModalPresentationIOS }} /> </ModalStack.Navigator> } ```
Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro. |
@cixio feel free to send a PR. the function name is likey minified in production and causing this. so the fix would be to do something like this: i !==
findLastIndex((scenes, scene) => {
const { cardStyleInterpolator } = scene.descriptor.options;
return (
cardStyleInterpolator === forModalPresentationIOS ||
cardStyleInterpolator?.name === "forModalPresentationIOS"
);
}); The implementation of const findLastIndex = (array, callback) => {
for (var i = array.length - 1; i >= 0; i--) {
if (callback(array[i])) {
return i;
}
}
return -1;
}; |
I'd love to do a PR, but I honestly have no idea what's going on here. I could only determine that the bug must be due to this change. Sorry :( |
@cixio please try |
works perfekt. thanks! 🥇 |
…s well (#11209) We got a custom `cardStyleInterpolator` in our app that actually calls [forModalPresentationIOS](https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx#L93) but we add some own customizations to it. This worked fine in `v5` of react-navigation, and started to act weird after the upgrade to `v6`, the screen under the modal was displayed right until the animation was finished, then the screen under disappeared, which is unintended. This PR just checks for the name instead. Making it do the same as this check: https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/views/Stack/Card.tsx#L580 and will allow for custom cardStyleInterpolators. This can be reproduced by creating your own cardStyleIntepolator and then call `forModalPresentationIOS`: ```ts import type {StackCardInterpolationProps} from "@react-navigation/stack"; import {CardStyleInterpolators} from "@react-navigation/stack"; export const forModalPresentationIOS = ({ index, current, next, inverted, layouts, insets, ...rest }: StackCardInterpolationProps) => { const defaultAnimations = CardStyleInterpolators.forModalPresentationIOS({ index, current, next, inverted, layouts, insets, ...rest, }); return defaultAnimations }; const ModalStack = createStackNavigator<ModalStackParamList>(); export function ModalNavigator() { return ( <ModalStack.Navigator> <ModalStack.Screen name='Modal' component={() => <View />} options={{ gestureEnabled: true, gestureDirection: "vertical", cardOverlayEnabled: true, cardStyleInterpolator: forModalPresentationIOS }} /> </ModalStack.Navigator> } ```
…s well (#11209) We got a custom `cardStyleInterpolator` in our app that actually calls [forModalPresentationIOS](https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/TransitionConfigs/CardStyleInterpolators.tsx#L93) but we add some own customizations to it. This worked fine in `v5` of react-navigation, and started to act weird after the upgrade to `v6`, the screen under the modal was displayed right until the animation was finished, then the screen under disappeared, which is unintended. This PR just checks for the name instead. Making it do the same as this check: https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/views/Stack/Card.tsx#L580 and will allow for custom cardStyleInterpolators. This can be reproduced by creating your own cardStyleIntepolator and then call `forModalPresentationIOS`: ```ts import type {StackCardInterpolationProps} from "@react-navigation/stack"; import {CardStyleInterpolators} from "@react-navigation/stack"; export const forModalPresentationIOS = ({ index, current, next, inverted, layouts, insets, ...rest }: StackCardInterpolationProps) => { const defaultAnimations = CardStyleInterpolators.forModalPresentationIOS({ index, current, next, inverted, layouts, insets, ...rest, }); return defaultAnimations }; const ModalStack = createStackNavigator<ModalStackParamList>(); export function ModalNavigator() { return ( <ModalStack.Navigator> <ModalStack.Screen name='Modal' component={() => <View />} options={{ gestureEnabled: true, gestureDirection: "vertical", cardOverlayEnabled: true, cardStyleInterpolator: forModalPresentationIOS }} /> </ModalStack.Navigator> } ```
We got a custom
cardStyleInterpolator
in our app that actually calls forModalPresentationIOS but we add some own customizations to it. This worked fine inv5
of react-navigation, and started to act weird after the upgrade tov6
, the screen under the modal was displayed right until the animation was finished, then the screen under disappeared, which is unintended.This PR just checks for the name instead. Making it do the same as this check: https://github.com/react-navigation/react-navigation/blob/main/packages/stack/src/views/Stack/Card.tsx#L580 and will allow for custom cardStyleInterpolators.
This can be reproduced by creating your own cardStyleIntepolator and then call
forModalPresentationIOS
: