I have a few CRUD pages that with following routes:
Product List
- Product Detail
Category List
- Category Detail, showing all products that belong to this category
Detail pages have a IonBackButton that has a defaultHref to the List page.
I wanted to allow user to jump to a product detail page from the Category Detail -> product list. This works fine, but when pressing the IonBackButton from the Product Detail it goes back to the Product List.
Looking into the source of IonBackButton, I realized that this behavior is as per design. BackButton implementation does not use window.history at all. Instead it first checks if ion-nav is used for navigation (ostensibly for private navigation within a modal) and if so uses its navigation stack. If not, it defaults to navigating back to the URL in defaultHref.
First question is, why is window.history not used as a navigation stack in IonBackButton? Wouldn’t it make more sense to use defaultHref only if window.history.length == 0?
Secondly, how can I design a navigation solution that suits my requirements? Should I change the secondary detail page to a modal rather than router navigation to a page? That would mean that the Detail page would have to be capable of handling two types of renderings – one as a page and one as a modal. Is this usually done?
Thanks in advance.
1 post - 1 participant