Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/libs/Navigation/OnyxTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {MaterialTopTabNavigationEventMap} from '@react-navigation/material-
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import type {EventMapCore, NavigationState, ParamListBase, ScreenListeners} from '@react-navigation/native';
import {useRoute} from '@react-navigation/native';
import React, {useCallback, useContext, useEffect, useMemo, useState} from 'react';
import React, {useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react';
import FocusTrapContainerElement from '@components/FocusTrap/FocusTrapContainerElement';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import type {TabSelectorProps} from '@components/TabSelector/types';
Expand Down Expand Up @@ -105,6 +105,7 @@ function OnyxTabNavigator<TTabName extends string = SelectedTabRequest>({
equalWidth = false,
...rest
}: OnyxTabNavigatorProps<TTabName>) {
const isFirstMountRef = useRef(true);
// Mapping of tab name to focus trap container element
const [focusTrapContainerElementMapping, setFocusTrapContainerElementMapping] = useState<Record<string, HTMLElement>>({});
const [selectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${id}`);
Expand Down Expand Up @@ -177,6 +178,10 @@ function OnyxTabNavigator<TTabName extends string = SelectedTabRequest>({
const state = event.data.state;
const index = state.index;
const routeNames = state.routeNames;
if (isFirstMountRef.current) {
onTabSelect?.({index});
isFirstMountRef.current = false;
}
const newSelectedTab = routeNames.at(index);
if (selectedTab === newSelectedTab) {
return;
Expand Down
Loading