ionic-team / ionic-team/ionic-framework
feat: Swipe back to `defaultHref` page
- 主要语言
- TypeScript
- 星标
- 52.7k
- 派生
- 13.3k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 51
描述
### Prerequisites
- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/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:
1. `/feeds` - List of feeds
2. `/feeds/:name` - Feed by name
3. `/` - 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 `` 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 `` 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 `` 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 of `defaultHref` 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.
贡献指南
评估
这个 Issue 还没有评估数据。