You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Ionic React navigate with push from useIonRouter ignores direction when used as "replace" #24260
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v4.x
v5.x
v6.x
Current Behavior
using Ionic React and useIonRouter the direction is not respected if the route action is "replace". It always goes "forward"
If the action is "push" (the default) all directions respected.
Expected Behavior
Direction of the router should behave based on function call - no matter the route action.
Steps to Reproduce
In the repo, fire up the app and you should go to the EXAMPLE menu item. Here there are three links to detail pages.
Detail 1 has a button to redirect using "replace" with direction "none" - this will redirect but animate using "forward"
Detail 2 has a button to redirect using default behavior ("push") with direction "none" - this will redirect and have no page transition animation.
in my use case I just wanted to use 'none' as routerDirection to remove the page animation. My workaround was to pass the animationBuilder property and use an empty animation like that:
Same issue with v6.x. I also noticed that it works only if there is no history yet. For example, if the first push is a back with replace then it will work properly with a back animation. But then all following push calls (with replace) will result in a back transition, regardless if the routerDirection is back or forward. Analog behavior if the first push is a forward.
So, a push with a replace seems to ignore the routerDirection unless it is the first call with no history yet.
in my use case I just wanted to use 'none' as routerDirection to remove the page animation. My workaround was to pass the animationBuilder property and use an empty animation like that:
@TylerAHolden Unfortunately that doesn't solve it for me, the swipe back animation still doesn't work (due to forcing it off from createAnimation() call)
@TylerAHolden Unfortunately that doesn't solve it for me, the swipe back animation still doesn't work (due to forcing it off from createAnimation() call)
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
gregorgretz commentedon Nov 29, 2021
i stumbled across the same problem and can confirm the described behavior
fr3fou commentedon Dec 21, 2021
any updates? I've been dealing with the same thing
gregorgretz commentedon Dec 22, 2021
in my use case I just wanted to use 'none' as routerDirection to remove the page animation. My workaround was to pass the animationBuilder property and use an empty animation like that:
router.push(n.href, 'none', 'replace', {}, createAnimation());maybe this will help someone
ankrut commentedon Mar 25, 2022
Same issue with
v6.x. I also noticed that it works only if there is no history yet. For example, if the firstpushis abackwithreplacethen it will work properly with abackanimation. But then all followingpushcalls (withreplace) will result in abacktransition, regardless if the routerDirection isbackorforward. Analog behavior if the firstpushis aforward.So, a
pushwith areplaceseems to ignore the routerDirection unless it is the first call with no history yet.I found the following workaround
aeharding commentedon Dec 1, 2023
This works, the only drawback is that the swipe back animation is broken.
TylerAHolden commentedon Dec 7, 2023
I do not know why it works but I had to do a mix of both of these solutions....
aeharding commentedon Dec 7, 2023
@TylerAHolden Unfortunately that doesn't solve it for me, the swipe back animation still doesn't work (due to forcing it off from
createAnimation()call)TylerAHolden commentedon Dec 7, 2023
Ah yes the swipe back still doesn't work.
liamdebeasi commentedon Dec 8, 2023
Hi everyone,
Here is a dev build with a proposed fix if anyone is interested in testing:
fix(react): replacing route uses new route direction and animation (#…
ionitron-bot commentedon Jan 10, 2024
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.