From 9e7fab0817b91eddb945fe317d0a306618a779d0 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Mon, 15 Apr 2024 00:38:44 +0530 Subject: [PATCH] fix: No hover effect for an already selected option. Signed-off-by: Krishna Gupta --- src/components/SelectionList/BaseListItem.tsx | 3 ++- src/components/SelectionList/TableListItem.tsx | 1 + src/components/SelectionList/types.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/SelectionList/BaseListItem.tsx b/src/components/SelectionList/BaseListItem.tsx index 5f4438f18f60..fe9ccc55711b 100644 --- a/src/components/SelectionList/BaseListItem.tsx +++ b/src/components/SelectionList/BaseListItem.tsx @@ -29,6 +29,7 @@ function BaseListItem({ children, isFocused, onFocus = () => {}, + hoverStyle, }: BaseListItemProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -68,7 +69,7 @@ function BaseListItem({ accessibilityLabel={item.text ?? ''} role={CONST.ROLE.BUTTON} hoverDimmingValue={1} - hoverStyle={!item.isDisabled && !item.isSelected && styles.hoveredComponentBG} + hoverStyle={[!item.isDisabled && styles.hoveredComponentBG, hoverStyle]} dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} onMouseDown={shouldPreventDefaultFocusOnSelectRow ? (e) => e.preventDefault() : undefined} nativeID={keyForList ?? ''} diff --git a/src/components/SelectionList/TableListItem.tsx b/src/components/SelectionList/TableListItem.tsx index cc87d84baf03..b330706f34ae 100644 --- a/src/components/SelectionList/TableListItem.tsx +++ b/src/components/SelectionList/TableListItem.tsx @@ -58,6 +58,7 @@ function TableListItem({ pendingAction={item.pendingAction} keyForList={item.keyForList} onFocus={onFocus} + hoverStyle={item.isSelected && styles.activeComponentBG} > {(hovered) => ( <> diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index e15dea542be6..3e6e3c1a0bca 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -147,6 +147,7 @@ type BaseListItemProps = CommonListItemProps & { pendingAction?: PendingAction | null; FooterComponent?: ReactElement; children?: ReactElement | ((hovered: boolean) => ReactElement); + hoverStyle?: StyleProp; }; type UserListItemProps = ListItemProps & {