From 19696e6b4ff7822fd62526ab4a42b56b29f6514c Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Wed, 25 Nov 2026 16:29:28 -0800 Subject: [PATCH 1/2] fix(tabs): name the missing tab in the getTab error --- core/src/components.d.ts | 8 +++---- core/src/components/tabs/tabs.tsx | 17 ++++++++++---- core/src/components/tabs/test/tabs.spec.ts | 27 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 core/src/components/tabs/test/tabs.spec.ts diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 42fff08fdfe..5eba056cad8 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -3309,16 +3309,16 @@ export namespace Components { interface IonTabs { "getRouteId": () => Promise; /** - * Get the currently selected tab. This method is only available for vanilla JavaScript projects. The Angular, React, and Vue implementations of tabs are coupled to each framework's router. + * Get the currently selected tab. In React and Vue, this method only works when tabs are used without a router outlet. */ "getSelected": () => Promise; /** - * Get a specific tab by the value of its `tab` property or an element reference. This method is only available for vanilla JavaScript projects. The Angular, React, and Vue implementations of tabs are coupled to each framework's router. - * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property. + * Get a specific tab by the value of its `tab` property or an element reference. In React and Vue, this method only works when tabs are used without a router outlet. + * @param tab The tab instance to get. If passed a string, it should be the value of the tab's `tab` property. */ "getTab": (tab: string | HTMLIonTabElement) => Promise; /** - * Select a tab by the value of its `tab` property or an element reference. This method is only available for vanilla JavaScript projects. The Angular, React, and Vue implementations of tabs are coupled to each framework's router. + * Select a tab by the value of its `tab` property or an element reference. In React and Vue, this method only works when tabs are used without a router outlet. With a router outlet, tabs are coupled to the framework's router, so navigate with the router instead. * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property. */ "select": (tab: string | HTMLIonTabElement) => Promise; diff --git a/core/src/components/tabs/tabs.tsx b/core/src/components/tabs/tabs.tsx index 20f4d84d136..18c7bdf5ba7 100644 --- a/core/src/components/tabs/tabs.tsx +++ b/core/src/components/tabs/tabs.tsx @@ -95,7 +95,10 @@ export class Tabs implements NavOutlet { } /** - * Select a tab by the value of its `tab` property or an element reference. This method is only available for vanilla JavaScript projects. The Angular, React, and Vue implementations of tabs are coupled to each framework's router. + * Select a tab by the value of its `tab` property or an element reference. + * + * In React and Vue, this method only works when tabs are used without a router outlet. With a router outlet, + * tabs are coupled to the framework's router, so navigate with the router instead. * * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property. */ @@ -113,9 +116,11 @@ export class Tabs implements NavOutlet { } /** - * Get a specific tab by the value of its `tab` property or an element reference. This method is only available for vanilla JavaScript projects. The Angular, React, and Vue implementations of tabs are coupled to each framework's router. + * Get a specific tab by the value of its `tab` property or an element reference. + * + * In React and Vue, this method only works when tabs are used without a router outlet. * - * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property. + * @param tab The tab instance to get. If passed a string, it should be the value of the tab's `tab` property. */ @Method() async getTab(tab: string | HTMLIonTabElement): Promise { @@ -123,7 +128,9 @@ export class Tabs implements NavOutlet { } /** - * Get the currently selected tab. This method is only available for vanilla JavaScript projects. The Angular, React, and Vue implementations of tabs are coupled to each framework's router. + * Get the currently selected tab. + * + * In React and Vue, this method only works when tabs are used without a router outlet. */ @Method() getSelected(): Promise { @@ -233,7 +240,7 @@ const getTab = (tabs: HTMLIonTabElement[], tab: string | HTMLIonTabElement): HTM const tabEl = typeof tab === 'string' ? tabs.find((t) => t.tab === tab) : tab; if (!tabEl) { - printIonError(`[ion-tabs] - Tab with id: "${tabEl}" does not exist`); + printIonError(`[ion-tabs] - Tab with id: "${tab}" does not exist`); } return tabEl; }; diff --git a/core/src/components/tabs/test/tabs.spec.ts b/core/src/components/tabs/test/tabs.spec.ts new file mode 100644 index 00000000000..bddb2d0caee --- /dev/null +++ b/core/src/components/tabs/test/tabs.spec.ts @@ -0,0 +1,27 @@ +import { newSpecPage } from '@stencil/core/testing'; + +import { Tab } from '../../tab/tab'; +import { Tabs } from '../tabs'; + +describe('tabs: getTab', () => { + it('should name the requested tab when it does not exist', async () => { + const page = await newSpecPage({ + components: [Tabs, Tab], + html: ` + + Home + + `, + }); + + const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {}); + + const tabs = page.body.querySelector('ion-tabs')!; + const tab = await tabs.getTab('settings'); + + expect(tab).toBeUndefined(); + expect(consoleError).toHaveBeenCalledWith('[Ionic Error]: [ion-tabs] - Tab with id: "settings" does not exist'); + + consoleError.mockRestore(); + }); +}); From e3f6907e3a36c923ff49156b7d6cc2427beb59ce Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Wed, 25 Nov 2026 16:37:45 -0800 Subject: [PATCH 2/2] chore(tabs): regenerate components.d.ts --- core/src/components.d.ts | 6 +++--- core/src/components/tabs/tabs.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 5eba056cad8..78bbf19d1c6 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -3309,16 +3309,16 @@ export namespace Components { interface IonTabs { "getRouteId": () => Promise; /** - * Get the currently selected tab. In React and Vue, this method only works when tabs are used without a router outlet. + * Get the currently selected tab. In React and Vue, this method only works when tabs are used without a router outlet. */ "getSelected": () => Promise; /** - * Get a specific tab by the value of its `tab` property or an element reference. In React and Vue, this method only works when tabs are used without a router outlet. + * Get a specific tab by the value of its `tab` property or an element reference. In React and Vue, this method only works when tabs are used without a router outlet. * @param tab The tab instance to get. If passed a string, it should be the value of the tab's `tab` property. */ "getTab": (tab: string | HTMLIonTabElement) => Promise; /** - * Select a tab by the value of its `tab` property or an element reference. In React and Vue, this method only works when tabs are used without a router outlet. With a router outlet, tabs are coupled to the framework's router, so navigate with the router instead. + * Select a tab by the value of its `tab` property or an element reference. In React and Vue, this method only works when tabs are used without a router outlet. With a router outlet, tabs are coupled to the framework's router, so navigate with the router instead. * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property. */ "select": (tab: string | HTMLIonTabElement) => Promise; diff --git a/core/src/components/tabs/tabs.tsx b/core/src/components/tabs/tabs.tsx index 18c7bdf5ba7..9881ae6ae13 100644 --- a/core/src/components/tabs/tabs.tsx +++ b/core/src/components/tabs/tabs.tsx @@ -96,7 +96,7 @@ export class Tabs implements NavOutlet { /** * Select a tab by the value of its `tab` property or an element reference. - * + * * In React and Vue, this method only works when tabs are used without a router outlet. With a router outlet, * tabs are coupled to the framework's router, so navigate with the router instead. * @@ -117,7 +117,7 @@ export class Tabs implements NavOutlet { /** * Get a specific tab by the value of its `tab` property or an element reference. - * + * * In React and Vue, this method only works when tabs are used without a router outlet. * * @param tab The tab instance to get. If passed a string, it should be the value of the tab's `tab` property. @@ -129,7 +129,7 @@ export class Tabs implements NavOutlet { /** * Get the currently selected tab. - * + * * In React and Vue, this method only works when tabs are used without a router outlet. */ @Method()