Skip to content

Commit 0b86ba3

Browse files
authored
Merge pull request Expensify#67468 from bernhardoj/fix/67341-selected-bg-isnt-applied-correctly
Fix selected unreported expense item background isn't full
2 parents b814042 + bb8ec58 commit 0b86ba3

6 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/components/MoneyRequestReportView/MoneyRequestReportTransactionItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function MoneyRequestReportTransactionItem({
140140
onCheckboxPress={toggleTransaction}
141141
columns={allReportColumns}
142142
isDisabled={isPendingDelete}
143+
style={[styles.p3]}
143144
/>
144145
</PressableWithFeedback>
145146
</OfflineWithFeedback>

src/components/SelectionList/Search/TransactionGroupListItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
5353
const {translate} = useLocalize();
5454
const isEmpty = groupItem.transactions.length === 0;
5555
const isDisabledOrEmpty = isEmpty || isDisabled;
56-
const {isLargeScreenWidth} = useResponsiveLayout();
56+
const {isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
5757

5858
const {amountColumnSize, dateColumnSize, taxAmountColumnSize} = useMemo(() => {
5959
const isAmountColumnWide = groupItem.transactions.some((transaction) => transaction.isAmountColumnWide);
@@ -206,7 +206,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
206206
onButtonPress={() => {
207207
openReportInRHP(transaction);
208208
}}
209-
columnWrapperStyles={[styles.ph3, styles.pv1Half]}
209+
style={[styles.noBorderRadius, shouldUseNarrowLayout ? [styles.p3, styles.pt2] : [styles.ph3, styles.pv1Half]]}
210210
isReportItemChild
211211
isInSingleTransactionReport={groupItem.transactions.length === 1}
212212
/>

src/components/SelectionList/Search/TransactionListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function TransactionListItem<TItem extends ListItem>({
163163
amountColumnSize={amountColumnSize}
164164
taxAmountColumnSize={taxAmountColumnSize}
165165
shouldShowCheckbox={!!canSelectMultiple}
166+
style={[styles.p3, shouldUseNarrowLayout ? styles.pt2 : {}]}
166167
/>
167168
</PressableWithFeedback>
168169
</OfflineWithFeedback>

src/components/Skeletons/UnreportedExpensesSkeleton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function UnreportedExpensesSkeleton({fixedNumberOfItems}: {fixedNumberOfItems?:
3636
const [pageWidth, setPageWidth] = React.useState(0);
3737
useLayoutEffect(() => {
3838
containerRef.current?.measure((x, y, width) => {
39-
setPageWidth(width - 24);
39+
setPageWidth(width - 40);
4040
});
4141
}, []);
4242

@@ -85,7 +85,7 @@ function UnreportedExpensesSkeleton({fixedNumberOfItems}: {fixedNumberOfItems?:
8585
>
8686
<ItemListSkeletonView
8787
itemViewHeight={64}
88-
itemViewStyle={[styles.highlightBG, styles.mb2, styles.br2, styles.ml3, styles.mr3]}
88+
itemViewStyle={[styles.highlightBG, styles.mb2, styles.br2, styles.ml5, styles.mr5]}
8989
shouldAnimate
9090
fixedNumItems={fixedNumberOfItems}
9191
renderSkeletonItem={skeletonItem}

src/components/TransactionItemRow/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {useMemo} from 'react';
22
import {View} from 'react-native';
3-
import type {ViewStyle} from 'react-native';
3+
import type {StyleProp, ViewStyle} from 'react-native';
44
import type {ValueOf} from 'type-fest';
55
import Checkbox from '@components/Checkbox';
66
import type {TransactionWithOptionalHighlight} from '@components/MoneyRequestReportView/MoneyRequestReportTransactionList';
@@ -88,7 +88,7 @@ type TransactionItemRowProps = {
8888
shouldShowCheckbox: boolean;
8989
columns?: Array<ValueOf<typeof CONST.REPORT.TRANSACTION_LIST.COLUMNS>>;
9090
onButtonPress?: () => void;
91-
columnWrapperStyles?: ViewStyle[];
91+
style?: StyleProp<ViewStyle>;
9292
isReportItemChild?: boolean;
9393
isActionLoading?: boolean;
9494
isInSingleTransactionReport?: boolean;
@@ -128,7 +128,7 @@ function TransactionItemRow({
128128
shouldShowCheckbox = false,
129129
columns,
130130
onButtonPress = () => {},
131-
columnWrapperStyles,
131+
style,
132132
isReportItemChild = false,
133133
isActionLoading,
134134
isInSingleTransactionReport = false,
@@ -347,14 +347,13 @@ function TransactionItemRow({
347347
transactionItem,
348348
],
349349
);
350-
const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius];
351350
const shouldRenderChatBubbleCell = useMemo(() => {
352351
return columns?.includes(CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS) ?? false;
353352
}, [columns]);
354353

355354
if (shouldUseNarrowLayout) {
356355
return (
357-
<View style={[styles.expenseWidgetRadius, styles.justifyContentEvenly, styles.p3, styles.pt2, bgActiveStyles]}>
356+
<View style={[styles.expenseWidgetRadius, styles.justifyContentEvenly, bgActiveStyles, style, styles.overflowHidden]}>
358357
<View style={[styles.flexRow]}>
359358
{shouldShowCheckbox && (
360359
<Checkbox
@@ -448,7 +447,7 @@ function TransactionItemRow({
448447
}
449448

450449
return (
451-
<View style={[...safeColumnWrapperStyle, styles.flex1, styles.gap2, bgActiveStyles, styles.mw100]}>
450+
<View style={[styles.expenseWidgetRadius, styles.flex1, styles.gap2, bgActiveStyles, styles.mw100, style]}>
452451
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3]}>
453452
<Checkbox
454453
disabled={isDisabled}

src/pages/UnreportedExpenseListItem.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function UnreportedExpenseListItem<TItem extends ListItem>({item, isFocused, sho
1919
const [isSelected, setIsSelected] = useState<boolean>(false);
2020
const theme = useTheme();
2121

22-
const pressableStyle = [styles.transactionListItemStyle, item.isSelected && styles.activeComponentBG];
22+
const pressableStyle = [styles.transactionListItemStyle, isSelected && styles.activeComponentBG];
2323

2424
const animatedHighlightStyle = useAnimatedHighlightStyle({
2525
borderRadius: variables.componentBorderRadius,
@@ -40,18 +40,15 @@ function UnreportedExpenseListItem<TItem extends ListItem>({item, isFocused, sho
4040
onSelectRow(item);
4141
setIsSelected((val) => !val);
4242
}}
43-
disabled={isDisabled && !item.isSelected}
43+
disabled={isDisabled && !isSelected}
4444
accessibilityLabel={item.text ?? ''}
4545
role={getButtonRole(true)}
4646
isNested
4747
onMouseDown={(e) => e.preventDefault()}
48-
hoverStyle={[!item.isDisabled && styles.hoveredComponentBG, item.isSelected && styles.activeComponentBG]}
48+
hoverStyle={[!item.isDisabled && styles.hoveredComponentBG, isSelected && styles.activeComponentBG]}
4949
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true, [CONST.INNER_BOX_SHADOW_ELEMENT]: false}}
5050
id={item.keyForList ?? ''}
51-
style={[
52-
pressableStyle,
53-
isFocused && StyleUtils.getItemBackgroundColorStyle(!!item.isSelected, !!isFocused, !!item.isDisabled, theme.activeComponentBG, theme.hoverComponentBG),
54-
]}
51+
style={[pressableStyle, isFocused && StyleUtils.getItemBackgroundColorStyle(!!isSelected, !!isFocused, !!item.isDisabled, theme.activeComponentBG, theme.hoverComponentBG)]}
5552
onFocus={onFocus}
5653
wrapperStyle={[styles.mb2, styles.mh5, styles.flex1, animatedHighlightStyle, styles.userSelectNone]}
5754
>
@@ -68,6 +65,7 @@ function UnreportedExpenseListItem<TItem extends ListItem>({item, isFocused, sho
6865
setIsSelected((val) => !val);
6966
}}
7067
shouldShowCheckbox
68+
style={styles.p3}
7169
/>
7270
</PressableWithFeedback>
7371
</OfflineWithFeedback>

0 commit comments

Comments
 (0)