Skip to content

Commit

Permalink
Revert "fix: On selecting a category/ tags by multiple tapping, user …
Browse files Browse the repository at this point in the history
…directed to conversation page."
  • Loading branch information
yuwenmemon authored Jan 29, 2025
1 parent 242b4c9 commit bd7fc43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
4 changes: 0 additions & 4 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,6 @@ function BaseSelectionList<TItem extends ListItem>(
*/
const selectRow = useCallback(
(item: TItem, indexToFocus?: number) => {
if (!isFocused) {
return;
}
// In single-selection lists we don't care about updating the focused index, because the list is closed after selecting an item
if (canSelectMultiple) {
if (sections.length > 1) {
Expand Down Expand Up @@ -404,7 +401,6 @@ function BaseSelectionList<TItem extends ListItem>(
setFocusedIndex,
onSelectRow,
shouldPreventDefaultFocusOnSelectRow,
isFocused,
],
);

Expand Down
7 changes: 6 additions & 1 deletion src/pages/WorkspaceSwitcherPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import React, {useCallback, useMemo} from 'react';
import {useOnyx} from 'react-native-onyx';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
Expand Down Expand Up @@ -38,6 +39,7 @@ function WorkspaceSwitcherPage() {
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const {translate} = useLocalize();
const {activeWorkspaceID, setActiveWorkspaceID} = useActiveWorkspace();
const isFocused = useIsFocused();

const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS);
Expand Down Expand Up @@ -81,14 +83,17 @@ function WorkspaceSwitcherPage() {

const selectPolicy = useCallback(
(policyID?: string) => {
if (!isFocused) {
return;
}
const newPolicyID = policyID === activeWorkspaceID ? undefined : policyID;

Navigation.goBack();
// On native platforms, we will see a blank screen if we navigate to a new HomeScreen route while navigating back at the same time.
// Therefore we delay switching the workspace until after back navigation, using the InteractionManager.
switchPolicyAfterInteractions(newPolicyID, () => setActiveWorkspaceID(newPolicyID));
},
[activeWorkspaceID, setActiveWorkspaceID],
[activeWorkspaceID, setActiveWorkspaceID, isFocused],
);

const usersWorkspaces = useMemo<WorkspaceListItem[]>(() => {
Expand Down
10 changes: 0 additions & 10 deletions tests/unit/BaseSelectionListTest.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as NativeNavigation from '@react-navigation/native';
import {fireEvent, render, screen} from '@testing-library/react-native';
import BaseSelectionList from '@components/SelectionList/BaseSelectionList';
import RadioListItem from '@components/SelectionList/RadioListItem';
Expand Down Expand Up @@ -42,15 +41,7 @@ describe('BaseSelectionList', () => {
);
}

it('should not trigger item press if screen is not focused', () => {
(NativeNavigation.useIsFocused as jest.Mock).mockReturnValue(false);
render(<BaseListItemRenderer sections={mockSections} />);
fireEvent.press(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}1`));
expect(onSelectRowMock).toHaveBeenCalledTimes(0);
});

it('should handle item press correctly', () => {
(NativeNavigation.useIsFocused as jest.Mock).mockReturnValue(true);
render(<BaseListItemRenderer sections={mockSections} />);
fireEvent.press(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}1`));
expect(onSelectRowMock).toHaveBeenCalledWith({
Expand All @@ -64,7 +55,6 @@ describe('BaseSelectionList', () => {
...section,
isSelected: section.keyForList === '2',
}));
(NativeNavigation.useIsFocused as jest.Mock).mockReturnValue(true);
const {rerender} = render(<BaseListItemRenderer sections={mockSections} />);
expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}1`)).toBeSelected();
rerender(<BaseListItemRenderer sections={updatedMockSections} />);
Expand Down

0 comments on commit bd7fc43

Please sign in to comment.