Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we're passing shouldUseSuccessStyle as false here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for View action which doesn't use the success style.

const buttonInnerStyles = isSelected ? styles.buttonDefaultHovered : {};

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
Loading