diff --git a/src/CONST.ts b/src/CONST.ts
index 13b79179f431..36c535bc1ae2 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -2803,7 +2803,7 @@ const CONST = {
HORIZONTAL_SPACER: {
DEFAULT_BORDER_BOTTOM_WIDTH: 1,
DEFAULT_MARGIN_VERTICAL: 8,
- HIDDEN_MARGIN_VERTICAL: 0,
+ HIDDEN_MARGIN_VERTICAL: 4,
HIDDEN_BORDER_BOTTOM_WIDTH: 0,
},
diff --git a/src/components/SpacerView.js b/src/components/SpacerView.js
index 60ff7fd85e55..9509219c0ac7 100644
--- a/src/components/SpacerView.js
+++ b/src/components/SpacerView.js
@@ -1,6 +1,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
+import usePrevious from '@hooks/usePrevious';
import stylePropTypes from '@styles/stylePropTypes';
import * as StyleUtils from '@styles/StyleUtils';
import CONST from '@src/CONST';
@@ -23,22 +24,30 @@ const defaultProps = {
};
function SpacerView({shouldShow = true, style = []}) {
- const marginVertical = useSharedValue(CONST.HORIZONTAL_SPACER.DEFAULT_MARGIN_VERTICAL);
- const borderBottomWidth = useSharedValue(CONST.HORIZONTAL_SPACER.DEFAULT_BORDER_BOTTOM_WIDTH);
+ const marginVertical = useSharedValue(shouldShow ? CONST.HORIZONTAL_SPACER.DEFAULT_MARGIN_VERTICAL : CONST.HORIZONTAL_SPACER.HIDDEN_MARGIN_VERTICAL);
+ const borderBottomWidth = useSharedValue(shouldShow ? CONST.HORIZONTAL_SPACER.DEFAULT_BORDER_BOTTOM_WIDTH : CONST.HORIZONTAL_SPACER.HIDDEN_BORDER_BOTTOM_WIDTH);
+ const prevShouldShow = usePrevious(shouldShow);
+
+ const duration = CONST.ANIMATED_TRANSITION;
const animatedStyles = useAnimatedStyle(() => ({
- marginVertical: marginVertical.value,
- borderBottomWidth: borderBottomWidth.value,
+ borderBottomWidth: withTiming(borderBottomWidth.value, {duration}),
+ marginTop: withTiming(marginVertical.value, {duration}),
+ marginBottom: withTiming(marginVertical.value, {duration}),
}));
React.useEffect(() => {
- const duration = CONST.ANIMATED_TRANSITION;
+ if (shouldShow === prevShouldShow) {
+ return;
+ }
const values = {
marginVertical: shouldShow ? CONST.HORIZONTAL_SPACER.DEFAULT_MARGIN_VERTICAL : CONST.HORIZONTAL_SPACER.HIDDEN_MARGIN_VERTICAL,
borderBottomWidth: shouldShow ? CONST.HORIZONTAL_SPACER.DEFAULT_BORDER_BOTTOM_WIDTH : CONST.HORIZONTAL_SPACER.HIDDEN_BORDER_BOTTOM_WIDTH,
};
- marginVertical.value = withTiming(values.marginVertical, {duration});
- borderBottomWidth.value = withTiming(values.borderBottomWidth, {duration});
- }, [shouldShow, borderBottomWidth, marginVertical]);
+ marginVertical.value = values.marginVertical;
+ borderBottomWidth.value = values.borderBottomWidth;
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- we only need to trigger when shouldShow prop is changed
+ }, [shouldShow, prevShouldShow]);
return ;
}
diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js
index 2b073d7fee34..26ee4a3dc08d 100644
--- a/src/pages/home/report/ReportActionItem.js
+++ b/src/pages/home/report/ReportActionItem.js
@@ -568,15 +568,9 @@ function ReportActionItem(props) {
};
if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) {
- let content = (
-
- );
const parentReportAction = ReportActionsUtils.getParentReportAction(props.report);
if (ReportActionsUtils.isTransactionThread(parentReportAction)) {
- content = (
+ return (
@@ -602,22 +596,21 @@ function ReportActionItem(props) {
>
);
- } else {
- content = (
- <>
-
-
-
-
- >
- );
}
+ return (
+ <>
+
+
+
+
+ >
+ );
}
if (ReportUtils.isExpenseReport(props.report) || ReportUtils.isIOUReport(props.report)) {
- content = (
+ return (
{content};
+ return (
+
+ );
}
if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) {
return ;