Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: On selecting a category/ tags by multiple tapping, user directed to conversation page." #56000

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
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
Loading