diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 6a6b27eacdca..f55d6b283676 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -123,7 +123,8 @@ type MoneyReportHeaderProps = { function MoneyReportHeader({policy, report: moneyRequestReport, transactionThreadReportID, reportActions, shouldDisplayBackButton = false, onBackButtonPress}: MoneyReportHeaderProps) { // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to use a correct layout for the hold expense modal https://github.com/Expensify/App/pull/47990#issuecomment-2362382026 // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); + const {shouldUseNarrowLayout, isSmallScreenWidth, isMediumScreenWidth} = useResponsiveLayout(); + const shouldDisplayNarrowVersion = shouldUseNarrowLayout || isMediumScreenWidth; const route = useRoute(); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`, {canBeMissing: true}); @@ -699,7 +700,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea shouldShowBorderBottom={false} shouldEnableDetailPageNavigation > - {!shouldUseNarrowLayout && ( + {!shouldDisplayNarrowVersion && ( {!!primaryAction && !shouldShowSelectedTransactionsButton && primaryActionsImplementation[primaryAction]} {!!applicableSecondaryActions.length && !shouldShowSelectedTransactionsButton && ( @@ -712,7 +713,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea isSplitButton={false} /> )} - {shouldShowSelectedTransactionsButton && !shouldUseNarrowLayout && ( + {shouldShowSelectedTransactionsButton && ( null} @@ -726,10 +727,10 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea )} - {shouldUseNarrowLayout && ( + {shouldDisplayNarrowVersion && !shouldShowSelectedTransactionsButton && ( - {!!primaryAction && !shouldShowSelectedTransactionsButton && {primaryActionsImplementation[primaryAction]}} - {!!applicableSecondaryActions.length && !shouldShowSelectedTransactionsButton && ( + {!!primaryAction && {primaryActionsImplementation[primaryAction]}} + {!!applicableSecondaryActions.length && ( {}} @@ -744,8 +745,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea )} {isMoreContentShown && ( - - {shouldShowSelectedTransactionsButton && shouldUseNarrowLayout && ( + {shouldShowSelectedTransactionsButton && shouldDisplayNarrowVersion && ( + null} options={selectedTransactionsOptions} @@ -754,8 +755,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea shouldAlwaysShowDropdownMenu wrapperStyle={styles.w100} /> - )} - + + )} {shouldShowNextStep && } {!!statusBarProps && ( (''); @@ -178,9 +177,9 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, const listHorizontalPadding = styles.ph5; return !isEmpty(transactions) ? ( <> - {!displayNarrowVersion && ( - - + {!shouldUseNarrowLayout && ( + + { if (selectedTransactionsID.length === transactions.length) { @@ -193,20 +192,23 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, isIndeterminate={selectedTransactionsID.length > 0 && selectedTransactionsID.length !== transactions.length} isChecked={selectedTransactionsID.length === transactions.length} /> + {isMediumScreenWidth && {translate('workspace.people.selectAll')}} - { - if (!isSortableColumnName(selectedSortBy)) { - return; - } - - setSortConfig((prevState) => ({...prevState, sortBy: selectedSortBy, sortOrder: selectedSortOrder})); - }} - /> + {!isMediumScreenWidth && ( + { + if (!isSortableColumnName(selectedSortBy)) { + return; + } + + setSortConfig((prevState) => ({...prevState, sortBy: selectedSortBy, sortOrder: selectedSortOrder})); + }} + /> + )} )} @@ -236,7 +238,7 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, style={[pressableStyle]} onMouseLeave={handleMouseLeave} onLongPress={() => { - if (!displayNarrowVersion) { + if (!shouldUseNarrowLayout) { return; } if (selectionMode?.isEnabled) { @@ -252,7 +254,8 @@ function MoneyRequestReportTransactionList({report, transactions, reportActions, isSelected={isTransactionSelected(transaction.transactionID)} dateColumnSize={dateColumnSize} shouldShowTooltip - shouldUseNarrowLayout={displayNarrowVersion} + shouldUseNarrowLayout={shouldUseNarrowLayout || isMediumScreenWidth} + shouldShowCheckbox={!!selectionMode?.isEnabled || isMediumScreenWidth} shouldShowChatBubbleComponent onCheckboxPress={toggleTransaction} /> diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 15bfb54791be..af2a28f995a3 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -8,7 +8,6 @@ import DateCell from '@components/SelectionList/Search/DateCell'; import Text from '@components/Text'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useHover from '@hooks/useHover'; -import useMobileSelectionMode from '@hooks/useMobileSelectionMode'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -27,6 +26,7 @@ import TransactionItemRowRBR from './TransactionItemRowRBR'; function TransactionItemRow({ transactionItem, shouldUseNarrowLayout, + shouldShowCheckbox, isSelected, shouldShowTooltip, dateColumnSize, @@ -35,6 +35,7 @@ function TransactionItemRow({ }: { transactionItem: TransactionWithOptionalHighlight; shouldUseNarrowLayout: boolean; + shouldShowCheckbox: boolean; isSelected: boolean; shouldShowTooltip: boolean; dateColumnSize: TableColumnSize; @@ -57,7 +58,6 @@ function TransactionItemRow({ backgroundColor: theme.highlightBG, }); - const {selectionMode} = useMobileSelectionMode(); const {hovered, bind: bindHover} = useHover(); const bgActiveStyles = useMemo(() => { if (isSelected) { @@ -79,7 +79,7 @@ function TransactionItemRow({ - {!!selectionMode?.isEnabled && ( + {shouldShowCheckbox && ( { diff --git a/src/stories/TransactionItemRow.stories.tsx b/src/stories/TransactionItemRow.stories.tsx index 123617b85fed..98bf6d767847 100644 --- a/src/stories/TransactionItemRow.stories.tsx +++ b/src/stories/TransactionItemRow.stories.tsx @@ -1,5 +1,6 @@ import type {Meta, StoryFn} from '@storybook/react'; import React from 'react'; +import ScreenWrapper from '@components/ScreenWrapper'; import ThemeProvider from '@components/ThemeProvider'; import ThemeStylesProvider from '@components/ThemeStylesProvider'; import TransactionItemRow from '@components/TransactionItemRow'; @@ -14,6 +15,7 @@ type TransactionItemRowProps = { shouldUseNarrowLayout: boolean; isSelected: boolean; shouldShowTooltip: boolean; + shouldShowCheckbox: boolean; }; const story: Meta = { @@ -38,28 +40,37 @@ const story: Meta = { shouldShowTooltip: { control: 'boolean', }, + shouldShowCheckbox: { + control: 'boolean', + }, }, parameters: { useLightTheme: true, }, }; -function Template({transactionItem, shouldUseNarrowLayout, isSelected, shouldShowTooltip}: TransactionItemRowProps, {parameters}: {parameters: {useLightTheme?: boolean}}) { +function Template( + {transactionItem, shouldUseNarrowLayout, isSelected, shouldShowTooltip, shouldShowCheckbox}: TransactionItemRowProps, + {parameters}: {parameters: {useLightTheme?: boolean}}, +) { const theme = parameters.useLightTheme ? CONST.THEME.LIGHT : CONST.THEME.DARK; return ( - - {}} - /> - + + + {}} + /> + + ); }