From d07e69a47d3386a0d8a5585f44cd1d2ac2fb53fb Mon Sep 17 00:00:00 2001 From: Zuzanna Furtak Date: Fri, 17 Oct 2025 13:22:12 +0200 Subject: [PATCH 1/2] Make CategoryDefaultTaxRatePage use new SelectionList --- .../categories/CategoryDefaultTaxRatePage.tsx | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx b/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx index fde675c9c78f..52eee4b5cce0 100644 --- a/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx +++ b/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx @@ -1,9 +1,9 @@ import React, {useCallback, useMemo} from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; -import SelectionList from '@components/SelectionListWithSections'; -import RadioListItem from '@components/SelectionListWithSections/RadioListItem'; -import type {ListItem} from '@components/SelectionListWithSections/types'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/ListItem/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; import useLocalize from '@hooks/useLocalize'; import usePolicy from '@hooks/usePolicy'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -48,6 +48,23 @@ function CategoryDefaultTaxRatePage({ .sort((a, b) => localeCompare(a.text ?? a.keyForList ?? '', b.text ?? b.keyForList ?? '')); }, [policy, selectedTaxRate, textForDefault, localeCompare]); + const handleSelectRow = useCallback( + (item: ListItem) => { + if (!item.keyForList) { + return; + } + + if (item.keyForList === selectedTaxRate) { + Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, categoryName)); + return; + } + + setPolicyCategoryTax(policyID, categoryName, item.keyForList); + Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, categoryName))); + }, + [policyID, categoryName, selectedTaxRate], + ); + return ( Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, categoryName))} /> { - if (!item.keyForList) { - return; - } - - if (item.keyForList === selectedTaxRate) { - Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, categoryName)); - return; - } - - setPolicyCategoryTax(policyID, categoryName, item.keyForList); - Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.goBack(ROUTES.WORKSPACE_CATEGORY_SETTINGS.getRoute(policyID, categoryName))); - }} + onSelectRow={handleSelectRow} shouldSingleExecuteRowSelect - containerStyle={[styles.pt3]} - initiallyFocusedOptionKey={selectedTaxRate} addBottomSafeAreaPadding + initiallyFocusedItemKey={selectedTaxRate} + listStyle={styles.pt3} /> From 76fb07a19977b5ff5d175e2994a5af25c6f96cc8 Mon Sep 17 00:00:00 2001 From: Zuzanna Furtak Date: Fri, 17 Oct 2025 16:29:28 +0200 Subject: [PATCH 2/2] Adjust style --- .../SelectionList/BaseSelectionList.tsx | 12 +++++------- src/components/SelectionList/types.ts | 17 +++++++++++------ .../categories/CategoryDefaultTaxRatePage.tsx | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index 93f59d358eb3..53bf81d1e53d 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -51,9 +51,7 @@ function BaseSelectionList({ rightHandSideComponent, alternateNumberOfSupportedLines, selectedItems = CONST.EMPTY_ARRAY, - listStyle, - listItemTitleStyles, - listItemWrapperStyle, + style, isSelected, isSmallScreenWidth, isLoadingNewOptions, @@ -311,8 +309,8 @@ function BaseSelectionList({ isAlternateTextMultilineSupported={!!alternateNumberOfSupportedLines} alternateTextNumberOfLines={alternateNumberOfSupportedLines} shouldIgnoreFocus={shouldIgnoreFocus} - wrapperStyle={listItemWrapperStyle} - titleStyles={listItemTitleStyles} + wrapperStyle={style?.listItemWrapperStyle} + titleStyles={style?.listItemTitleStyles} singleExecution={singleExecution} /> ); @@ -365,7 +363,7 @@ function BaseSelectionList({ useImperativeHandle(ref, () => ({scrollAndHighlightItem, scrollToIndex}), [scrollAndHighlightItem, scrollToIndex]); return ( - + {textInputComponent({shouldBeInsideList: false})} {data.length === 0 ? ( renderListEmptyContent() @@ -391,7 +389,7 @@ function BaseSelectionList({ showsVerticalScrollIndicator={showScrollIndicator} onEndReached={onEndReached} onEndReachedThreshold={onEndReachedThreshold} - style={listStyle as ViewStyle} + style={style?.listStyle as ViewStyle} initialScrollIndex={initialFocusedIndex} onScrollBeginDrag={onScrollBeginDrag} ListHeaderComponent={ diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 5b4247e4f724..1b4f086605a6 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -64,14 +64,19 @@ type SelectionListProps = { /** Array of selected item keys */ selectedItems?: readonly string[]; - /** Styles to apply to the list */ - listStyle?: StyleProp; + style?: { + /** Styles to apply to the list */ + listStyle?: StyleProp; - /** Styles applied for the title of the list item */ - listItemTitleStyles?: StyleProp; + /** Styles applied for the title of the list item */ + listItemTitleStyles?: StyleProp; - /** Styles for the list item wrapper */ - listItemWrapperStyle?: StyleProp; + /** Styles for the list item wrapper */ + listItemWrapperStyle?: StyleProp; + + /** Styles to apply to the list container */ + containerStyle?: StyleProp; + }; /** Function that determines if an item is selected */ isSelected?: (item: TItem) => boolean; diff --git a/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx b/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx index 52eee4b5cce0..c46868f8e541 100644 --- a/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx +++ b/src/pages/workspace/categories/CategoryDefaultTaxRatePage.tsx @@ -88,7 +88,7 @@ function CategoryDefaultTaxRatePage({ shouldSingleExecuteRowSelect addBottomSafeAreaPadding initiallyFocusedItemKey={selectedTaxRate} - listStyle={styles.pt3} + style={{containerStyle: styles.pt3}} />