-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Navigation stops working #13695
Comments
Perhaps a duplicate of #13538 ? @williambuchanan2 Have you tried wrapping the navigation calls with There's an extensions class for |
Hi @williambuchanan2. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
I tried that but it doesn't make any difference. |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our [Triage Process] (https://github.com/dotnet/maui/blob/main/docs/TriageProcess.md). |
Just checking if there is any progress on this? |
@williambuchanan2 if you await your shell navigation then it will surface helpful exception messages |
Hi @williambuchanan2. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Hi @PureWeen, I had noticed those errors. The trouble is when you follow the advice given in the error messages you just get another error. BTW, I didn't know whether I had to take the advice in the error literally (i.e. use ///: ///) because that format doesn't seem to be documented anywhere, so I tried all the below: await Shell.Current.GoToAsync("///: ///TabH"); await Shell.Current.GoToAsync("///TabH"); await Shell.Current.GoToAsync("//TabH"); Either way - none of the above works. I then try the other method (which again works some of the time):
But it just does nothing, and doesn't throw an error, so I have no idea why on this occasion it doesn't want to work. I guess I am doing something wrong somewhere, but it would be good to have some kind of consistent way of navigating without having to worry about it randomly not working. Why does everything work ok, and then for some unknown reason the same code just no longer works? |
It is only for Scenario 1 to describe. Doesn't this mean that the route name defined in AppShell.xaml has multiple TabHs and There are two definitions of TabH.
It seems that it is not possible to decide which TabH to transition to. Change the definition of AppShell.xaml as follows.
Specify the name of Login in the Route of ShellItem. Try using //Login/TabH as the argument of the GoToAsync method called Since the method needs to be modified, it will not work as it is.
At least as far as I tried, it navigated to TabH. As an aside, I think that if you delete all TabH definitions in AppShell.xaml, it will work as intended. I'm not sure what you're expecting, so I'm sorry if I'm wrong. |
Hi @cat0363 Thank you. Yes, you are right. 🥇 I had misunderstood what Route meant. I thought it was to take you to that route (i.e. the route to take when you click = 'TabH'). I didn't realise it actually creates a duplicate item with that name. Any thoughts on Scenario 2? :-) |
In order to coexist Scenario 1 and Scenario 2, it is necessary to change as follows.
Scenario 2 resulted in the following exception:
Therefore, I deleted the unnecessary Route definition. In addition to the above, you should:(Below is what I posted yesterday.)
At least I did the above and it worked. Isn't this a Discussion, not an Issue? Since I don't know the detailed expected result and the code is complicated, I can't write more. |
Hi @cat0363 Thanks. Yes that also seems to work. So it's fair to say the problems were to do with the way I implemented this. I didn't realise that the AppShell could be structured like that. However, just to cover off some of the points you raised. Firstly, a couple of people from Microsoft have looked at this and provided comments which didn't fix the problem, so they clearly couldn't work out the problem either. That in itself tells me that a) this thing isn't documented well enough, and b) there should have been some kind of meaningful error message and/or compiler warning (if as you say it is generating duplicates, then surely we should be warned because this is going to cause a problem). The fact that it works some of the time just makes it more confusing than if it didn't work at all. The documentation shows some very basic examples but doesn't explain any of what you have explained. What I had done was in line with the documentation (in fact I copied the example code as my start point). The error message that gets thrown actually gives you advice which doesn't work, so rather than help it just makes things worse because I then lost time trying to follow that advice. As for raising this as a discussion - we have lost months going round in circles trying to get things working, assuming we are doing something wrong, then finally coming to the conclusion that it must be a bug. We are at the point now where as soon as something doesn't work we just naturally assume it is yet another bug and then move on to something else rather than try to fix it. But honestly - what difference does it make raising it as a discussion? Nothing is really getting addressed anyway so it doesn't make any difference. Thank you for your help. At least I can move on from this problem, although I would argue that some changes should be made to prevent others from having this problem. |
If you've reported it as a bug, you should at least detail the expected result. The above might have led to a quicker solution to the problem. If you post it in Discussion, it will catch more people's eyes. I think it's an advantage. As you said, I think that the following pages should have explanations for each exception. Since there is no explanation in the documentation, I ended up looking for similar issues on various forums. |
I also ran into edge cases where the back button would break the navigation behaviour in Android. I was unable to figure out why the navigation broke reproducably in certain scenarios. In my case it happened once i hit the back button to navigate up in the stack. That led to images not being loaded anymore (or more accurately it was rendered but then disappeared) and accessing the same page again left me with a blank page. I fixed my issue by removing the page once the back button is pressed, which then shows the previous page as i intended. Shell.Current.CurrentPage.Navigation.RemovePage(Shell.Current.CurrentPage); |
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on android platform with sample project. |
@samhouts could the fix @MissedSte4k mentioned be backported to .net7? |
@williambuchanan2 apologies on the late reply here I'm having a little trouble following what parts of the documentation would be best to improve here. It seems like you had two routes with the same name so |
@PureWeen, I think the biggest issue is that navigation is broken in .net 7 if there's an image on the shell. That makes it kinda hard to release.. |
I don't think the documentation is the real problem. I think using the word "Ambiguous" in the error is the main issue, but in general the way the error is dealt with is confusing. Yes, I misunderstood how the shell parameters worked (my bad), but had I straight away seen an error telling me there are "duplicate" routes (rather than Ambiguous) I might have had a better chance of working it out. What happens is everything seems to work ok for a while, and no error message gets thrown (unless you know to await the call) - all this adds to the confusion. So, my thoughts in hindsight are: For the documentation - I assumed that the "route" was just the name of the view you want to load, so I didn't think anything of the fact that I had the same one twice. Seems obvious now but I don't think the documentation even mentions "Route" so pretty sure I was left guessing... |
@williambuchanan2 you can use images, you simply have to null the variable before setting it and navigation stops breaking. I tested it in the latest .net7 build and it worked in Android 13. sample: source: |
Duplicate of #14052 |
We'll see if we can safely backport the fix to NET 7, friends! :) |
@samhouts that would be great. I also ran into the issue when using Camera.Maui and trying to scan a barcode on android. Removing the page from the stack isn't a viable solution in this case, as i want to pass the query parameter. Could you provide some info if this will be backported and when the next SR will be? Thanks! |
It looks like the related fix is pending merge: #16640. I would not expect this to be available until October at this point. If by any chance this does not resolve your issue, please submit a new one for your specific scenario. This issue may have multiple root causes. If you're able to test with NET 8 previews today, that could speed up the resolution. Thanks! |
Description
I am using the following to navigate (as per example app in linked repository below):
Shell.Current.GoToAsync or
Shell.Current.FindByName with Shell.Current.CurrentItem = xxx
Both work ok, and then for no apparent reason stop working.
My guess is i'm doing something wrong, but even if that is the case some kind of exception or information would be nice. Literally nothing happens. The app just doesn't navigate and I have no idea why.
There are different scenarios that cause it. I have managed to reliably reproduce 2 of them in the example.
Steps to Reproduce
Look at the example in the repository link below.
Scenario 1 - just keep clicking Next. When you get to Page 16 the next button stops working. The code being called - I have tried both navigate methods (1 of them is commented out) but neither works.
Scenario 2 - click the Scenario 2 button on the first page then keep clicking next. Then when you get to around page 4 notice that the back button stops working.
Link to public reproduction project repository
https://github.com/williambuchanan2/MauiNavigation.git
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 11 and 13
Did you find any workaround?
No. Need to kill the app and reload
Relevant log output
No response
The text was updated successfully, but these errors were encountered: