Skip to content

Commit

Permalink
Merge pull request #53920 from bernhardoj/fix/53897-approves-button-b…
Browse files Browse the repository at this point in the history
…ecomes-green-when-selected

Fix on hold expense action button on the search page becomes green when selected

(cherry picked from commit 8749259)

(CP triggered by luacmartins)
  • Loading branch information
Gonals authored and OSBotify committed Dec 12, 2024
1 parent d4bdab9 commit a418df7
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/components/SelectionList/Search/ActionCell.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useCallback} from 'react';
import {View} from 'react-native';
import Badge from '@components/Badge';
import Button from '@components/Button';
Expand Down Expand Up @@ -36,7 +36,7 @@ type ActionCellProps = {

function ActionCell({
action = CONST.SEARCH.ACTION_TYPES.VIEW,
shouldUseSuccessStyle = true,
shouldUseSuccessStyle: shouldUseSuccessStyleProp = true,
isLargeScreenWidth = true,
isSelected = false,
goToItem,
Expand All @@ -52,6 +52,16 @@ function ActionCell({

const text = translate(actionTranslationsMap[action]);

const getButtonInnerStyles = useCallback(
(shouldUseSuccessStyle: boolean) => {
if (!isSelected) {
return {};
}
return shouldUseSuccessStyle ? styles.buttonSuccessHovered : styles.buttonDefaultHovered;
},
[isSelected, styles],
);

const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || (parentAction === CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID);

if ((parentAction !== CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID) || action === CONST.SEARCH.ACTION_TYPES.DONE) {
Expand All @@ -78,30 +88,28 @@ function ActionCell({
}

if (action === CONST.SEARCH.ACTION_TYPES.VIEW || shouldUseViewAction) {
const buttonInnerStyles = isSelected ? styles.buttonDefaultHovered : {};
return isLargeScreenWidth ? (
<Button
text={translate(actionTranslationsMap[CONST.SEARCH.ACTION_TYPES.VIEW])}
onPress={goToItem}
small
style={[styles.w100]}
innerStyles={buttonInnerStyles}
innerStyles={getButtonInnerStyles(false)}
link={isChildListItem}
shouldUseDefaultHover={!isChildListItem}
/>
) : null;
}

const buttonInnerStyles = isSelected ? styles.buttonSuccessHovered : {};
return (
<Button
text={text}
onPress={goToItem}
small
style={[styles.w100]}
innerStyles={buttonInnerStyles}
innerStyles={getButtonInnerStyles(shouldUseSuccessStyleProp)}
isLoading={isLoading}
success={shouldUseSuccessStyle}
success={shouldUseSuccessStyleProp}
isDisabled={isOffline}
/>
);
Expand Down

0 comments on commit a418df7

Please sign in to comment.