1
- import { useFocusEffect } from '@react-navigation/native' ;
2
- import React , { useCallback , useMemo , useState } from 'react' ;
1
+ import { useFocusEffect , useIsFocused } from '@react-navigation/native' ;
2
+ import React , { useCallback , useEffect , useMemo , useState } from 'react' ;
3
3
import { ActivityIndicator , View } from 'react-native' ;
4
4
import { useOnyx } from 'react-native-onyx' ;
5
5
import Button from '@components/Button' ;
@@ -17,7 +17,6 @@ import SelectionListWithModal from '@components/SelectionListWithModal';
17
17
import CustomListHeader from '@components/SelectionListWithModal/CustomListHeader' ;
18
18
import Text from '@components/Text' ;
19
19
import TextLink from '@components/TextLink' ;
20
- import useCleanupSelectedOptions from '@hooks/useCleanupSelectedOptions' ;
21
20
import useEnvironment from '@hooks/useEnvironment' ;
22
21
import useLocalize from '@hooks/useLocalize' ;
23
22
import useMobileSelectionMode from '@hooks/useMobileSelectionMode' ;
@@ -52,8 +51,7 @@ function WorkspaceTaxesPage({
52
51
params : { policyID} ,
53
52
} ,
54
53
} : WorkspaceTaxesPageProps ) {
55
- // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
56
- const { shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout ( ) ;
54
+ const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
57
55
const styles = useThemeStyles ( ) ;
58
56
const theme = useTheme ( ) ;
59
57
const { translate} = useLocalize ( ) ;
@@ -63,6 +61,7 @@ function WorkspaceTaxesPage({
63
61
const { selectionMode} = useMobileSelectionMode ( ) ;
64
62
const defaultExternalID = policy ?. taxRates ?. defaultExternalID ;
65
63
const foreignTaxDefault = policy ?. taxRates ?. foreignTaxDefault ;
64
+ const isFocused = useIsFocused ( ) ;
66
65
const hasAccountingConnections = PolicyUtils . hasAccountingConnections ( policy ) ;
67
66
const [ connectionSyncProgress ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY_CONNECTION_SYNC_PROGRESS } ${ policy ?. id } ` ) ;
68
67
const isSyncInProgress = isConnectionInProgress ( connectionSyncProgress , policy ) ;
@@ -87,8 +86,12 @@ function WorkspaceTaxesPage({
87
86
} , [ fetchTaxes ] ) ,
88
87
) ;
89
88
90
- const cleanupSelectedOption = useCallback ( ( ) => setSelectedTaxesIDs ( [ ] ) , [ ] ) ;
91
- useCleanupSelectedOptions ( cleanupSelectedOption ) ;
89
+ useEffect ( ( ) => {
90
+ if ( isFocused ) {
91
+ return ;
92
+ }
93
+ setSelectedTaxesIDs ( [ ] ) ;
94
+ } , [ isFocused ] ) ;
92
95
93
96
const textForDefault = useCallback (
94
97
( taxID : string , taxRate : TaxRate ) : string => {
@@ -189,10 +192,6 @@ function WorkspaceTaxesPage({
189
192
if ( ! taxRate . keyForList ) {
190
193
return ;
191
194
}
192
- if ( isSmallScreenWidth && selectionMode ?. isEnabled ) {
193
- toggleTax ( taxRate ) ;
194
- return ;
195
- }
196
195
Navigation . navigate ( ROUTES . WORKSPACE_TAX_EDIT . getRoute ( policyID , taxRate . keyForList ) ) ;
197
196
} ;
198
197
0 commit comments