-
Notifications
You must be signed in to change notification settings - Fork 86
DeepLinker generated URL names with tabbed pages causes double / #153
Comments
This is to be expected. Since the tabs act as their own sub nav, with it's own navController instance, it gets it's own url segment. This is by design. |
Is there are a work around? I consider multiple // forced into a URL a slug a design flaw. |
This is the intended design. Since components can be loaded anywhere, saying the multiple blank |
I want full control over the URLs, and what you're saying is that it's by design. But it's actually a "design limitation". If I set |
Looking the tabs based starter with some simple links setup... // app.module.ts
imports: [
IonicModule.forRoot(MyApp, {}, {
links: [
{ component: AboutPage, segment: 'about', name: 'About' },
{ component: HomePage, segment: 'home', name: 'Home' },
{ component: ContactPage, segment: 'contact', name: 'Contact' },
]
})
], and a tabs.html <ion-tabs>
<ion-tab [root]="tab1Root" tabUrlPath="myTitle" tabTitle="Home" tabIcon="home"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>
</ion-tabs> my generated url for the first component, HomePage is |
Right. I'm saying I want it to be just |
Having tabUrlPath is needed in order to determine that you are trying to load a full tabs-based navigation stack and all the navController history that comes with it. |
I need to be able to control the URLs generated, such as |
Don't use tabs then. If you think about how tabs are a navcontroller with their own nested navcontroller's for each tab, then this makes sense. There is no "work around" for something that is working as intended. |
I see you closed the issue. I guarantee other users in the future are going to bring it up again, and again, and again. It's going to come up. Because of your refusal to acknowledge this as a bug or serious design limitation, I'm going to have to stop using tabs, which means needless development time and money. Frustrating. |
Hey @morrisonbrett, there are a few things in here that we can definitely address to make it easier to control the URLs you want. Ionic's router tries to serialize the current So, we need to add that. Secondly, the double root slash shouldn't exist, so that's a bug. We will put this on the list of things to look into soon. |
@mlynch @mhartington If I understand @morrisonbrett correctly, the issue is that sometimes there is no need to add url/path change when switching between tabs... Especially if you consider the fact, that on Android (or in any browser), when each tab MUST have an url and you switch tabs (say go from tab A to tab B), then pressing the back button (not the one on app navbar) will switch back tabs, not the page... that in many situations is not acceptable (imagine, that you made tabs switch like this: tab A to tab B, tab B to C, tab C to A, tab A to B.... pressing back button will jump from tab to tab....). So either there should be a possiblity to have no url change for tab switch or ability to control how hardware back button behaves in terms of tab url change. |
So @mlynch would make sense for you to create new issues, tag them as bugs, and cross-reference them back here? |
+1 on prioritize this bug. However recently I have seen many times Ionic team chose the prioritization based on treating Web as a second class citizenship. When Ionic1 was there, Nokia and Blackberry were still something, Windows Phone was in the horizon. But in 2016, it wouldn't be too attractive if the only thing Ionic does well is to support two platforms, iOs and Android When we started to evaluate Ionic, it promotes its Mobile-like User Experience with a Tab-structure. the Tab has been used by a lot of ionic developers. Telling them to "or you should just stop use Tab" doesn't seem very practical, nor very friendly to the ecosystem you worked very hard to build. There are many solutions to the problem, such as just give developer the control to set sub navigation controller in the specific path location. We all are developers we understand the schedule, the resource limit etc. But we really hope you prioritize in the way that best fit Ionic's market nitch. |
I filed a new issue that is related to this one: ionic-team/ionic-framework#9183 I think the reason why @morrisonbrett leaves the tabUrlPath empty is the same reason why I left segments empty in my DeepLinker config (as described in this topic: https://forum.ionicframework.com/t/how-do-i-let-tabs-play-well-with-deeplinker/67715). I do believe this is a bug and not just a documentation issue (I believe the documentation on the DeepLinker still has to be written?). The example I provided in the other issue is different from the example provided here, but it also concerns the DeepLinker + Tabs combination. |
@mhartington I took your advice. I ended up abandoning tabs because of this! I rolled my own "tab bar" styling, with active, etc.. Now each "tab" is a unique URL. |
Same problem here.... |
@Daskus1 I've provided a quick (dirty) fix to work around this issue: ionic-team/ionic-framework#9183 (comment) |
@Daskus1 I ended up abandoning tabs and creating the tab UI equivalent myself. |
In my opinion the Ionic Team should think about making this configurable, since a lot of people are having this specific usecase/problem with Tabs |
On a similar note, can someone please answer this? https://forum.ionicframework.com/t/ionic-2-deeplinker-angular-html5mode-urls-without/74530/ |
I've spent about a week thinking about this for my app. We have around 180 different pages, all originating from 5 main tabs but very much intertwined. TL/DR: Tabs and DeepLinker as-is will work for us. URLs will end up with redundant data, but that's an affordable trade-off to allow us to keep separate tab navigation stacks. That's the real question that each situation will have to answer. I think that if one's application doesn't need the separate stacks, @morrisonbrett's custom tab object solution is the best answer. To make this easier, the Ionic tab object itself really should support an option to use just one stack / one rootPage like @Daskus1 suggested. This is more of a feature request than a bug. If, however, your app can get some benefit from the separate stacks, I think the solution is just to give in to the Department of Redundancy Department's DeepLinker URLs. I tried and tried to come up with ways to remove the redundancy in our page URLs and still pick a tab and a page with page params, but it just wouldn't work. Well, the only way I could find for it to work would be for Ionic to give us a spot to parse the incoming URL ourselves. If my |
@btsiders agree. Makes a lot of sense. Here's how my code ended up, working well. Posting here if it helps anyone: Link Config Declaration:
Imports line indicating I don't want Angular type # in the URLs:
Logic that I put in my
|
Interesting. I wouldn't think three pages would work with the same 'account' segment, though. |
Hi. would you mind moving the conversation to the forum. |
@mhartington I modified a bit your links setup for the tabs based starter:
When I try to open |
@damirarh I had a some problem! did you solve it? |
@DarrenHou1993 no, not yet. |
I have similar problem with my application
My main page is the Tabs Page, with three tab (Home, About, Contact). Maybe I miss something ? |
@DarrenHou1993, thanks to @5im0n I finally managed to solve my problem. It didn't work for me because I didn't have Here's a working configuration:
While generated URLs aren't as nice any more, navigation now works correctly. |
+1 to prioritizing this as well. I was just trying to create a tabbed app with DeepLinkConfig, and I just ran into this issue. I'm glad I found it early on in my development so I don't waste my time on working on an issue that doesn't have a resolution yet. |
I worry @5im0n 's trouble too. |
@rdlabo, I've open an issue for this trouble #10356. |
@5im0n thanks!! If it can, I will use DeepLinks in PWA!! |
Hello guys!, Thanks for your support. Really appreciate your work! |
@mhartington Can you look at the way Grails handles deep linking perhaps? Try following their lead. Because when I set root to HomePage, why am I getting some sort of ghost URL state from last time I ran the app?. I want to be at http://localhost:8100/ not http://localhost:8100/#//jobs/jobs. Or something akin to that. I can't even overwrite url in browser, it just comes back the same. This is not intuitive. Is there a detailed blog post you can refer me to so I can get my head around your way of thinking? Then perhaps I can find a way to work around these issues. |
I completely understand why this is by design and I agree, but I do feel there is a way to allow for this without breaking the design paradigm: It would be sufficient if we were able to either:
This would:
In addition it would also be consistent with the idea that the tab control has a separate navigation stack. who is to say that nav stack need to follow the same configuration as its parent while this should be the fallback. I don't know enough about the life cycle of the NavController works and how it gets its deeplink information. Any comment from ionic side what it would take? |
Another approach would be:
Again this wouldn't break existing code user code, and because every page has a unique name it wouldn't break ionic code either. So question is if its possible to figure out in flight if a page is loaded from a tabs page. The biggest advantage of this approach is that it just extend existing configuration in a simple way to give devs more control incl disabling direct access as well as that it can be configured centrally as well as per page. I really like the ionic navigation and would love to use it for all our app + web projects (great to have one toolchain), but url control is a client facing issue in web projects. So its not about that devs want things their way (maybe a little :)), but for us its about constant complaining from customers, c level etc. I understand that ionic is currently mostly focused on mobile but this seems like a rather small feature request to make the platform that much more useful for web devs. |
Still open? |
Starting to use DeepLinker. Ran into this issue. Details simplified for brevity's sake:
I have a tab called 'users'. Here it is:
I want the URL via DeepLinker to be
localhost:8100/#/users
However, the DeepLinker will take that, inspect the
tabUrlPath
value, and add an extra/
The URL will be:
localhost:8100/#//users
I can put a word in the tabUrlPath - let's try the word 'account'.
The URL will be:
localhost:8100/#/account/users
So the problem is, if I put an empty string in
tabUrlPath
, the DeepLinker code should factor that in when generating the URL slug. The same problem happens when using thetabTitle
attribute. A blank title yields an extra slash.I hope someone can fix this. I'm pretty sure the code fix will be somewhere in here: https://github.com/driftyco/ionic/blob/504e6e0440032d5813566def22a57f0e410bc2c6/src/navigation/deep-linker.ts
The text was updated successfully, but these errors were encountered: