Add backSegment property to DeepLinkMetadata for dynamic navigation hierarchies
See original GitHub issueIonic version: (check one with “x”) [ ] 1.x [ ] 2.x [x] 3.x
I’m submitting a … (check one with “x”) [ ] bug report [x] feature request [ ] support request
Feature Request:
From what I’ve gathered, the deep link system limits us to a single dynamic level in a navigation hierarchy. The defaultHistory
array takes strings which correspond to class names of pages (or of the name
properties of DeepLinkMetadata
objects if used). The issue is that params can’t be passed backwards through the history, so hierarchies with multiple dynamic levels are a no-go right now.
I suggest adding a new property to the DeepLinkMetadata
type called backSegment
, which would look like something like this (assuming you landed on the 3rd level of a dynamic hierarchy):
@IonicPage({
name: '3rd',
segment: 'hierarchy/1st/:1stId/2nd/:2ndId/3rd/:3rdId',
backSegment: 'hierarchy/1st/:1stId/2nd/:2ndId'
})
The backSegment
would automatically grab current URL params (1stId
& 2ndId
) and pass them back through the hierarchy.
Clicking the back button would pop the 3rd
level and take you to the 2nd
level:
@IonicPage({
name: '2nd',
segment: 'hierarchy/1st/:1stId/2nd/:2ndId',
backSegment: 'hierarchy/1st/:1stId'
})
Rinse and repeat to pop the 2nd
and go back to the 1st
:
@IonicPage({
name: '1st',
segment: 'hierarchy/1st/:1stId',
backSegment: 'hierarchy'
})
1st
pops back to the root of the hierarchy (we are out of params to usher through):
@IonicPage({
name: 'Hierarchy',
segment: 'hierarchy',
backSegment: ''
})
And Hierarchy
can pop back to the home/default page of the site:
@IonicPage({
name: 'Home',
// Empty segments don't currently work. See links below.
segment: ''
})
Note also that there is only a single segment string, rather than an array of pages in a history. I don’t think a page should have to list its full history. If a page knows its backSegment
, and that parent knows its backSegment
, etc., the system should be intelligent enough to build the breadcrumb back to the root for a given page.
If you need the whole history at once (perhaps because lazy loading prevents you from inspecting DeepLinkMetadata
of parent pages up the hierarchy), then an array of backSegments
, while duplicative, would work as well:
@IonicPage({
name: '3rd',
segment: 'hierarchy/1st/:1stId/2nd/:2ndId/3rd/:3rdId',
// or historySegments?
backSegments: [
'hierarchy/1st/:1stId/2nd/:2ndId',
'hierarchy/1st/:1stId',
'hierarchy',
''
]
})
If possible, it would be cool to ditch the explicit page names in segments and just have params (so this would apply to the current segment
property as well as the suggested backSegment
). From the example above, it would look like this:
segment: 'hierarchy/:1stId/:2ndId/:3rdId'
The idea here is that pages are “implicit” in the organization of many hierarchies. If you consider the dog taxonomy example, having each layer (Kingdom, Phylum, Class, Order, Suborder, Family, Genus, and Species) in the URL is superfluous:
example.com/taxonomy/Kingdom/Animalia/Phylum/Chordata/Class/Mammalia/Order/Carnivora/Suborder/Caniformia/Family/Canidae/Genus/Canis/Species/C_lupus
vs. “implicit” pages:
example.com/taxonomy/Animalia/Chordata/Mammalia/Carnivora/Caniformia/Canidae/Canis/C_lupus
Some links regarding the empty segement, which is how I thought it would work:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:19
- Comments:5
This would really solve navigation issues right now. like I have a report page with this path
report/:id
which has an image details view under pathreport/:id/image/:id
If the image page has a
defaultHistory
of['report']
you would expect it to go fromreport/1/image/1
toreport/1
but it actually goes toreport/:id
which is a super annoying bug.Issue moved to: https://github.com/ionic-team/ionic-v3/issues/212