Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already include this feature request, without success.
Describe the Feature Request
Configurable option to swipe back to defaultHref
page.
Describe the Use Case
Say you have a feed-based app with the following routes:
/feeds
- List of feeds/feeds/:name
- Feed by name/
- Redirects to/feeds/home
Upon app load, the app redirects /
to /feeds/home
so the user can immediately start browsing their home feed.
However, the user may want to view a list of their feeds. So, there’s an <IonBackButton>
with defaultHref="/feeds"
and text="Feeds"
.
This works fine! However, the user has to manually press the back button to go back. They cannot swipe back to the feeds page since the feeds page isn’t mounted in the DOM.
One thing I keep hearing from users it it would be cool if they could use a swipe back gesture instead of needing to manually press the back button. Because the user can swipe back everywhere else in the app, it’s a little bit jarring when they cannot for this one page.
Describe Preferred Solution
I’ve been thinking of ways this could be cleanly implemented on Ionic’s side with a nice clean API, and one idea I had is: What if <IonBackButton>
had a premountDefaultHrefIfNeeded
attribute?
Essentially, when a page is loaded, if there is no page to swipe back to (e.g. defaultHref
will be utilized when back is clicked) then the defaultHref
page is premounted so that the user can swipe back to it.
Describe Alternatives
I’ve been trying many different ways to do this without a library-side change, including loading /feeds
and then immediately redirecting to /feeds/home
on load (works OKish, but many edge cases to deal with on a tabbed route setup and shows the page change animation on app start), and even tried using a <Nav>
virtual page for the feed list (couldn’t get it to work right).
Related Code
No response
Additional Information
- Page could be premounted on
IonViewDidEnter
with the contents ofdefaultHref
at that moment. This would ensure no animation performance issues. - If defaultHref is computed and defaultHref changes after
IonViewDidEnter
, it is ignored (since there is now a page in the history, defaultHref is no longer used) - In terms of HTML5 navigation, I think it should just replace the current route just like pressing the back button does.