Skip to content

fix(react): select tabs from IonTabsContext without a router outlet - #31830

Open
thetaPC wants to merge 3 commits into
mainfrom
FW-7814
Open

thetaPC wants to merge 3 commits into
mainfrom
FW-7814

Conversation

@thetaPC

@thetaPC thetaPC commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: resolves #30037


What is the current behavior?

When IonTabs has IonTab children instead of an IonRouterOutlet, it never provides IonTabsContext. Components inside the tabs get the context's empty default, so selectTab does nothing and returns false, and activeTab is always undefined.

Without a router outlet, function children don't render either. IonTabs calls the function but passes the function itself to ion-tabs, so the tabs are empty and React warns "Functions are not valid as a React child".

What is the new behavior?

  • IonTabs provides IonTabsContext when used without a router outlet.
  • selectTab switches tabs by calling select() on ion-tabs. It returns false for a tab that doesn't exist, as it does with a router outlet.
  • activeTab updates when the selected tab changes.
  • onIonTabsWillChange and onIonTabsDidChange still fire once per tab change.
  • Function children render without a router outlet, as they do with one.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 9.0.14-dev.11795666220.1ec8630c

The tabs test page without a router outlet (/tabs-basic) now has buttons that call selectTab and read activeTab. A new test page (/tabs-function-children) passes its tabs as function children. It needs as any, because the children type only accepts React.ReactNode. The new e2e tests use both pages.

@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 26, 2026 4:11am UTC

Request Review

@github-actions github-actions Bot added the package: react @ionic/react package label Nov 25, 2026
@thetaPC
thetaPC marked this pull request as ready for review November 25, 2026 23:09
@thetaPC
thetaPC requested a review from a team as a code owner November 25, 2026 23:09
@thetaPC
thetaPC requested a review from ShaneK November 25, 2026 23:09

This branch was successfully deployed

1 active deployment
Preview — ec8630ce Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: react @ionic/react package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Programmatically switching tabs in basic mode doesn't work

1 participant