Skip to content

Commit 1d96c3a

Browse files
kkafarclaude
andauthored
chore: review suggestions for #3759 (#3790)
## Description Applies review suggestions raised on #3759. Changes are kept in a separate branch to allow incremental review before squashing/merging into the target. ## Changes - `initialFocusedName` → `defaultRouteName`: clearer name that avoids "focused" terminology inconsistent with the rest of the API; JSDoc comment updated accordingly - Remove unused `TabsContainerWithDynamicRouteConfigs`, `TabsRouteConfigContext`, and `useTabsRouteConfigContext` — no call sites found in the codebase ## Test plan Verify that tab selection works correctly in the example app on both iOS and Android, and that the `defaultRouteName` prop correctly sets the initially selected tab. ## Checklist - [ ] Included code example that can be used to test this change. - [ ] Updated / created local changelog entries in relevant test files. - [ ] For visual changes, included screenshots / GIFs / recordings documenting the change. - [x] For API changes, updated relevant public types. - [ ] Ensured that CI passes --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6b2be87 commit 1d96c3a

10 files changed

Lines changed: 14 additions & 98 deletions

File tree

apps/src/shared/gamma/containers/tabs/TabsContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function TabsContainer(props: TabsContainerProps) {
3131

3232
const {
3333
routeConfigs,
34-
initialFocusedName,
34+
defaultRouteName,
3535
experimentalControlNavigationStateInJS,
3636
onTabSelected,
3737
...restProps
@@ -44,7 +44,7 @@ export function TabsContainer(props: TabsContainerProps) {
4444
React.Dispatch<TabsNavigationAction>,
4545
] = React.useReducer(
4646
tabsNavigationReducerWithLogging,
47-
{ routeConfigs, initialFocusedName },
47+
{ routeConfigs, defaultRouteName },
4848
determineInitialTabsContainerState,
4949
);
5050

apps/src/shared/gamma/containers/tabs/TabsContainer.types.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export type TabsContainerProps = Omit<
8787
> & {
8888
routeConfigs: TabRouteConfig[];
8989
/**
90-
* Name of the tab that should be focused initially.
90+
* Name of the tab that should be selected initially.
9191
* Defaults to the first tab if not provided.
9292
*/
93-
initialFocusedName?: string;
93+
defaultRouteName?: string;
9494
/**
9595
* Whether to control navigation state in JS.
9696
* Passed to Tabs.Host as experimentalControlNavigationStateInJS.

apps/src/shared/gamma/containers/tabs/TabsContainerWithDynamicRouteConfigs.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

apps/src/shared/gamma/containers/tabs/TabsContainerWithHostConfigContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
export function TabsContainerWithHostConfigContext(props: TabsContainerProps) {
2020
const {
2121
routeConfigs,
22-
initialFocusedName,
22+
defaultRouteName,
2323
experimentalControlNavigationStateInJS,
2424
...hostProps
2525
} = props;
@@ -42,7 +42,7 @@ export function TabsContainerWithHostConfigContext(props: TabsContainerProps) {
4242
<TabsHostConfigContext value={tabsHostConfigContext}>
4343
<TabsContainer
4444
routeConfigs={routeConfigs}
45-
initialFocusedName={initialFocusedName}
45+
defaultRouteName={defaultRouteName}
4646
experimentalControlNavigationStateInJS={
4747
experimentalControlNavigationStateInJS
4848
}

apps/src/shared/gamma/containers/tabs/contexts/TabsRouteConfigContext.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

apps/src/shared/gamma/containers/tabs/hooks/useTabsRouteConfigContext.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

apps/src/shared/gamma/containers/tabs/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ export type {
1313

1414
export type { TabsNavigationContextPayload } from './contexts/TabsNavigationContext';
1515
export type { TabsHostConfigContextPayload } from './contexts/TabsHostConfigContext';
16-
export type { TabsRouteConfigContextPayload } from './contexts/TabsRouteConfigContext';
1716

1817
export { useTabsNavigationContext } from './hooks/useTabsNavigationContext';
1918
export { useTabsHostConfig } from './hooks/useTabsHostConfig';
20-
export { useTabsRouteConfigContext } from './hooks/useTabsRouteConfigContext';
2119

2220
export { TabsContainer } from './TabsContainer';
23-
export { TabsContainerWithDynamicRouteConfigs } from './TabsContainerWithDynamicRouteConfigs';
2421
export { TabsContainerWithHostConfigContext } from './TabsContainerWithHostConfigContext';
2522
export { DEFAULT_TAB_ROUTE_OPTIONS } from './presets';

apps/src/shared/gamma/containers/tabs/reducer.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,22 @@ function createTabRouteFromConfig(config: TabRouteConfig): TabRoute {
147147

148148
export type TabsContainerStateInitArg = {
149149
routeConfigs: TabRouteConfig[];
150-
initialFocusedName?: string;
150+
defaultRouteName?: string;
151151
};
152152

153153
export function determineInitialTabsContainerState(
154154
arg: TabsContainerStateInitArg,
155155
): TabsContainerState {
156-
const { routeConfigs, initialFocusedName } = arg;
156+
const { routeConfigs, defaultRouteName } = arg;
157157

158158
const routes = routeConfigs.map(createTabRouteFromConfig);
159159

160160
let selectedRouteKey: string;
161-
if (initialFocusedName != null) {
162-
const matchingRoute = routes.find(r => r.name === initialFocusedName);
163-
if (matchingRoute == null) {
161+
if (defaultRouteName != null) {
162+
const matchingRoute = routes.find(r => r.name === defaultRouteName);
163+
if (!matchingRoute) {
164164
throw new Error(
165-
`[Tabs] initialFocusedName "${initialFocusedName}" does not match any route config name`,
165+
`[Tabs] defaultRouteName "${defaultRouteName}" does not match any route config name`,
166166
);
167167
}
168168
selectedRouteKey = matchingRoute.routeKey;

apps/src/tests/issue-tests/TestBottomTabs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function App() {
278278
}}>
279279
<TabsContainer
280280
routeConfigs={TAB_CONFIGS}
281-
initialFocusedName="Tab1"
281+
defaultRouteName="Tab1"
282282
ios={{
283283
tabBarTintColor: Colors.YellowLight100,
284284
tabBarMinimizeBehavior: 'onScrollDown',

apps/src/tests/issue-tests/TestBottomTabsOrientation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function ScreenStackTabs() {
201201

202202
return (
203203
<NavigationIndependentTree>
204-
<TabsContainer initialFocusedName="Auto" routeConfigs={routeConfigs} />
204+
<TabsContainer defaultRouteName="Auto" routeConfigs={routeConfigs} />
205205
</NavigationIndependentTree>
206206
);
207207
}

0 commit comments

Comments
 (0)