@@ -546,9 +546,9 @@ export const IonRouter = ({ children, registerHistoryListener }: PropsWithChildr
546546 * @param routeAnimation A custom animation builder to override the
547547 * default "back" animation.
548548 */
549- const handleNavigateBack = ( defaultHref : string | RouteInfo = '/' , routeAnimation ?: AnimationBuilder ) => {
549+ const handleNavigateBack = ( defaultHref ? : string | RouteInfo , routeAnimation ?: AnimationBuilder ) => {
550550 const config = getConfig ( ) ;
551- defaultHref = defaultHref ? defaultHref : config && config . get ( 'backButtonDefaultHref' as any ) ;
551+ defaultHref = defaultHref ?? ( config && config . get ( 'backButtonDefaultHref' as any ) ) ;
552552 const routeInfo = locationHistory . current . current ( ) ;
553553 // It's a linear navigation.
554554 if ( routeInfo && routeInfo . pushedByRoute ) {
@@ -590,17 +590,18 @@ export const IonRouter = ({ children, registerHistoryListener }: PropsWithChildr
590590 * `pushedByRoute` exists, but no corresponding previous entry in
591591 * the history stack.
592592 */
593- } else {
593+ } else if ( defaultHref ) {
594594 handleNavigate ( defaultHref as string , 'pop' , 'back' , routeAnimation ) ;
595595 }
596596 /**
597597 * No `pushedByRoute` (e.g., initial page load or tab root).
598- * Tabs with no back history should not navigate.
598+ * Navigate to defaultHref so the back button works on direct
599+ * deep-link loads (e.g., loading /tab1/child directly).
600+ * Only navigate when defaultHref is explicitly set. The core
601+ * back-button component hides itself when no defaultHref is
602+ * provided, so a click here means the user set one intentionally.
599603 */
600- } else {
601- if ( routeInfo && routeInfo . tab ) {
602- return ;
603- }
604+ } else if ( defaultHref ) {
604605 handleNavigate ( defaultHref as string , 'pop' , 'back' , routeAnimation ) ;
605606 }
606607 } ;
0 commit comments