Skip to content

Commit 4490ce5

Browse files
committed
test(react): general navigation improvement
1 parent a2e803a commit 4490ce5

File tree

6 files changed

+42
-36
lines changed

6 files changed

+42
-36
lines changed

packages/react/test/base/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const App: React.FC = () => (
4343
<IonApp>
4444
<IonReactRouter>
4545
<IonRouterOutlet>
46-
<Route path="/" component={Main} />
46+
<Route exact path="/" component={Main} />
4747
<Route path="/overlay-hooks" component={OverlayHooks} />
4848
<Route path="/overlay-components" component={OverlayComponents} />
4949
<Route path="/overlay-components/nested-popover" component={IonPopoverNested} />

packages/react/test/base/src/pages/Main.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ const Main: React.FC<MainProps> = () => {
4040
<IonItem routerLink="/tabs-basic">
4141
<IonLabel>Tabs with Basic Navigation</IonLabel>
4242
</IonItem>
43+
<IonItem routerLink="/tabs-direct-navigation">
44+
<IonLabel>Tabs with Direct Navigation</IonLabel>
45+
</IonItem>
4346
<IonItem routerLink="/icons">
4447
<IonLabel>Icons</IonLabel>
4548
</IonItem>

packages/react/test/base/src/pages/Tabs.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import React from 'react';
2-
import { IonLabel, IonRouterOutlet, IonTabBar, IonTabButton, IonTabs } from '@ionic/react';
2+
import { IonLabel, IonRouterOutlet, IonTabBar, IonTabButton, IonTabs, IonPage } from '@ionic/react';
33
import { Route, Redirect } from 'react-router';
44

55
interface TabsProps {}
66

77
const Tabs: React.FC<TabsProps> = () => {
88
return (
9-
<IonTabs>
10-
<IonRouterOutlet>
11-
<Redirect from="/tabs" to="/tabs/tab1" exact />
12-
<Route path="/tabs/tab1" render={() => <IonLabel>Tab 1</IonLabel>} />
13-
</IonRouterOutlet>
14-
<IonTabBar slot="bottom">
15-
<IonTabButton tab="tab1" onClick={() => window.alert('Tab was clicked')}>
16-
<IonLabel>Click Handler</IonLabel>
17-
</IonTabButton>
18-
</IonTabBar>
19-
</IonTabs>
9+
<IonPage>
10+
<IonTabs>
11+
<IonRouterOutlet>
12+
<Redirect from="/tabs" to="/tabs/tab1" exact />
13+
<Route path="/tabs/tab1" render={() => <IonLabel>Tab 1</IonLabel>} />
14+
</IonRouterOutlet>
15+
<IonTabBar slot="bottom">
16+
<IonTabButton tab="tab1" onClick={() => window.alert('Tab was clicked')}>
17+
<IonLabel>Click Handler</IonLabel>
18+
</IonTabButton>
19+
</IonTabBar>
20+
</IonTabs>
21+
</IonPage>
2022
);
2123
};
2224

packages/react/test/base/src/pages/TabsBasic.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { IonLabel, IonTabBar, IonTabButton, IonTabs, IonTab } from '@ionic/react';
2+
import { IonLabel, IonTabBar, IonTabButton, IonTabs, IonTab, IonPage } from '@ionic/react';
33

44
interface TabsProps {}
55

@@ -13,22 +13,24 @@ const TabsBasic: React.FC<TabsProps> = () => {
1313
};
1414

1515
return (
16-
<IonTabs onIonTabsWillChange={onTabWillChange} onIonTabsDidChange={onTabDidChange}>
17-
<IonTab tab="tab1">
18-
<IonLabel>Tab 1 Content</IonLabel>
19-
</IonTab>
20-
<IonTab tab="tab2">
21-
<IonLabel>Tab 2 Content</IonLabel>
22-
</IonTab>
23-
<IonTabBar slot="bottom">
24-
<IonTabButton tab="tab1">
25-
<IonLabel>Tab 1</IonLabel>
26-
</IonTabButton>
27-
<IonTabButton tab="tab2">
28-
<IonLabel>Tab 2</IonLabel>
29-
</IonTabButton>
30-
</IonTabBar>
31-
</IonTabs>
16+
<IonPage>
17+
<IonTabs onIonTabsWillChange={onTabWillChange} onIonTabsDidChange={onTabDidChange}>
18+
<IonTab tab="tab1">
19+
<IonLabel>Tab 1 Content</IonLabel>
20+
</IonTab>
21+
<IonTab tab="tab2">
22+
<IonLabel>Tab 2 Content</IonLabel>
23+
</IonTab>
24+
<IonTabBar slot="bottom">
25+
<IonTabButton tab="tab1">
26+
<IonLabel>Tab 1</IonLabel>
27+
</IonTabButton>
28+
<IonTabButton tab="tab2">
29+
<IonLabel>Tab 2</IonLabel>
30+
</IonTabButton>
31+
</IonTabBar>
32+
</IonTabs>
33+
</IonPage>
3234
);
3335
};
3436

packages/react/test/base/src/pages/TabsDirectNavigation.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ const TabsDirectNavigation: React.FC = () => {
7878
</IonTabButton>
7979

8080
<IonTabButton tab="library" href="/tabs-direct-navigation/library" data-testid="library-tab">
81-
<IonIcon icon={libraryOutline}></IonIcon>
81+
<IonIcon icon={libraryOutline}></IonIcon>
8282
<IonLabel>Library</IonLabel>
8383
</IonTabButton>
8484

8585
<IonTabButton tab="search" href="/tabs-direct-navigation/search" data-testid="search-tab">
8686
<IonIcon icon={searchOutline}></IonIcon>
8787
<IonLabel>Search</IonLabel>
8888
</IonTabButton>
89-
</IonTabBar>
90-
</IonTabs>
89+
</IonTabBar>
90+
</IonTabs>
9191
);
9292
};
9393

94-
export default TabsDirectNavigation;
94+
export default TabsDirectNavigation;

packages/react/test/base/tests/e2e/specs/components/tabs-direct-navigation.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ describe('Tabs Direct Navigation', () => {
2626
it('should update tab selection when navigating between tabs', () => {
2727
cy.visit('/tabs-direct-navigation/home');
2828
cy.get('[data-testid="home-tab"]').should('have.class', 'tab-selected');
29-
3029
cy.get('[data-testid="radio-tab"]').click();
3130
cy.get('[data-testid="radio-tab"]').should('have.class', 'tab-selected');
3231
cy.get('[data-testid="home-tab"]').should('not.have.class', 'tab-selected');
3332
cy.get('[data-testid="radio-content"]').should('be.visible');
3433
});
35-
});
34+
});

0 commit comments

Comments
 (0)