Skip to content

fix: Web - Persistence of Tax Selection When Navigating to Other Pages and Returning #40136

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

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useIsFocused} from '@react-navigation/native';
import {useFocusEffect, useIsFocused} from '@react-navigation/native';
import type {StackScreenProps} from '@react-navigation/stack';
import lodashIsEqual from 'lodash/isEqual';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
Expand Down Expand Up @@ -144,6 +144,12 @@ function WorkspaceMembersPage({policyMembers, personalDetails, invitedEmailsToAc
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isFocused]);

useFocusEffect(
useCallback(() => {
setSelectedEmployees([]);
}, []),
);

useEffect(() => {
validateSelection();
}, [preferredLocale, validateSelection]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function WorkspaceCategoriesPage({policy, policyCategories, route}: WorkspaceCat

useFocusEffect(
useCallback(() => {
setSelectedCategories({});
fetchCategories();
}, [fetchCategories]),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function PolicyDistanceRatesPage({policy, route}: PolicyDistanceRatesPageProps)

useFocusEffect(
useCallback(() => {
setSelectedDistanceRates([]);
fetchDistanceRates();
}, [fetchDistanceRates]),
);
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) {

useFocusEffect(
useCallback(() => {
setSelectedTags({});
fetchTags();
}, [fetchTags]),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clear the tags when losing focus (instead of when gaining focus) that way we can remove the rest of logic that's used to clear the tags e.g. when navigating to the settings page

(same applies for the rest of the pages)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I forgot about that, I was trying to follow this suggestion, but yes, we should clear the options when losing focus.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s77rt, updated, can you pls check again🙏🏻

Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function WorkspaceTaxesPage({

useFocusEffect(
useCallback(() => {
setSelectedTaxesIDs([]);
fetchTaxes();
}, [fetchTaxes]),
);
Expand Down
Loading