Skip to content

Commit b1ae310

Browse files
committed
Fix badge style regressions from #82210
- Add ListItemFocusContext so InviteMemberListItem can propagate isFocused to rightElement children. MemberRightIcon consumes this context to apply badgeDefaultActive when the row is focused, preventing the badge from blending into the activeComponentBG highlight. - Map DONE action to reportStatusBadge.closed in BadgeActionCell so the Done action badge matches the Done status badge color (pink).
1 parent 04b333d commit b1ae310

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/components/SelectionList/ListItem/InviteMemberListItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
55
import {useProductTrainingContext} from '@components/ProductTrainingContext';
66
import ReportActionAvatars from '@components/ReportActionAvatars';
77
import SelectCircle from '@components/SelectCircle';
8+
import {ListItemFocusContext} from '@components/SelectionList/ListItemFocusContext';
89
import Text from '@components/Text';
910
import TextWithTooltip from '@components/TextWithTooltip';
1011
import EducationalTooltip from '@components/Tooltip/EducationalTooltip';
@@ -153,7 +154,7 @@ function InviteMemberListItem<TItem extends ListItem>({
153154
/>
154155
)}
155156
</View>
156-
{!!item.rightElement && item.rightElement}
157+
{!!item.rightElement && <ListItemFocusContext.Provider value={{isFocused: !!isFocused}}>{item.rightElement}</ListItemFocusContext.Provider>}
157158
{!!shouldShowCheckBox && (
158159
<PressableWithFeedback
159160
onPress={handleCheckboxPress}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {createContext, useContext} from 'react';
2+
3+
type ListItemFocusContextValue = {
4+
isFocused: boolean;
5+
};
6+
7+
const ListItemFocusContext = createContext<ListItemFocusContextValue>({isFocused: false});
8+
9+
function useListItemFocus() {
10+
return useContext(ListItemFocusContext);
11+
}
12+
13+
export {ListItemFocusContext, useListItemFocus};

src/components/SelectionListWithSections/InviteMemberListItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
55
import {useProductTrainingContext} from '@components/ProductTrainingContext';
66
import ReportActionAvatars from '@components/ReportActionAvatars';
77
import SelectCircle from '@components/SelectCircle';
8+
import {ListItemFocusContext} from '@components/SelectionList/ListItemFocusContext';
89
import Text from '@components/Text';
910
import TextWithTooltip from '@components/TextWithTooltip';
1011
import EducationalTooltip from '@components/Tooltip/EducationalTooltip';
@@ -150,7 +151,7 @@ function InviteMemberListItem<TItem extends ListItem>({
150151
/>
151152
)}
152153
</View>
153-
{!!item.rightElement && item.rightElement}
154+
{!!item.rightElement && <ListItemFocusContext.Provider value={{isFocused: !!isFocused}}>{item.rightElement}</ListItemFocusContext.Provider>}
154155
{!!shouldShowCheckBox && (
155156
<PressableWithFeedback
156157
onPress={handleCheckboxPress}

src/components/SelectionListWithSections/Search/ActionCell/BadgeActionCell.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ function BadgeActionCell({action, isLargeScreenWidth, shouldDisablePointerEvents
2323
const StyleUtils = useStyleUtils();
2424
const text = translate(actionTranslationsMap[action]);
2525

26-
const badgeTheme = action === CONST.SEARCH.ACTION_TYPES.PAID ? theme.reportStatusBadge.paid : theme.reportStatusBadge.approved;
26+
const getBadgeTheme = () => {
27+
if (action === CONST.SEARCH.ACTION_TYPES.PAID) {
28+
return theme.reportStatusBadge.paid;
29+
}
30+
if (action === CONST.SEARCH.ACTION_TYPES.DONE) {
31+
return theme.reportStatusBadge.closed;
32+
}
33+
return theme.reportStatusBadge.approved;
34+
};
35+
const badgeTheme = getBadgeTheme();
2736

2837
return (
2938
<View

src/pages/workspace/MemberRightIcon.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from 'react';
22
import type {StyleProp, ViewStyle} from 'react-native';
33
import Badge from '@components/Badge';
4+
import {useListItemFocus} from '@components/SelectionList/ListItemFocusContext';
45
import useLocalize from '@hooks/useLocalize';
6+
import useThemeStyles from '@hooks/useThemeStyles';
57
import CONST from '@src/CONST';
68
import type {TranslationPaths} from '@src/languages/types';
79

@@ -14,6 +16,8 @@ type MemberRightIconProps = {
1416

1517
export default function MemberRightIcon({role, owner, login, badgeStyles}: MemberRightIconProps) {
1618
const {translate} = useLocalize();
19+
const styles = useThemeStyles();
20+
const {isFocused} = useListItemFocus();
1721

1822
let badgeText: TranslationPaths | undefined;
1923
if (owner && owner === login) {
@@ -27,7 +31,7 @@ export default function MemberRightIcon({role, owner, login, badgeStyles}: Membe
2731
return (
2832
<Badge
2933
text={translate(badgeText)}
30-
badgeStyles={badgeStyles}
34+
badgeStyles={[isFocused && styles.badgeDefaultActive, badgeStyles]}
3135
/>
3236
);
3337
}

0 commit comments

Comments
 (0)