TP-86177 | Regression Testing Click handling fix (#12806)

This commit is contained in:
Kshitij Pramod Ghongadi
2024-09-27 17:47:46 +05:30
committed by GitHub
parent a40fb56d2e
commit 76b61dcdc8
3 changed files with 29 additions and 15 deletions

View File

@@ -38,9 +38,10 @@ export const StyledLottie = ({
}, [lottieFieldData]);
if (!lottieFieldData?.url) return <></>;
return (
const { cta, actions } = lottieFieldData;
const isInteractive = (cta && handleClick) || (actions && handleActions);
return isInteractive ? (
<TouchableOpacity
disabled={!(lottieFieldData.cta || lottieFieldData.actions)}
onPress={handleLottieClick}
style={styles.touchableOpacity}
activeOpacity={1}
@@ -53,5 +54,13 @@ export const StyledLottie = ({
style={[styles.lottie, lottieFieldData?.lottieStyle]}
/>
</TouchableOpacity>
) : (
<LottieView
ref={animationRef}
source={{ uri: lottieFieldData?.url }}
autoPlay={lottieFieldData?.autoPlay ?? true}
loop={lottieFieldData?.loop ?? true}
style={[styles.lottie, lottieFieldData?.lottieStyle]}
/>
);
};

View File

@@ -127,22 +127,24 @@ const StyledTextComponent = ({
actionPayloadList: GenericActionPayload | undefined,
) => void;
}) => {
const { cta, actions } = textFieldData;
const handleTextClick = () => {
const { cta, actions } = textFieldData;
if (actions && handleActions) {
handleActions(null, actions);
} else if (cta && handleClick) {
handleClick(cta);
}
};
return (
<TouchableOpacity
disabled={!(textFieldData.cta || textFieldData.actions)}
onPress={handleTextClick}
activeOpacity={1}
>
const isInteractive = (cta && handleClick) || (actions && handleActions);
return isInteractive ? (
<TouchableOpacity onPress={handleTextClick} activeOpacity={1}>
<TextComponent textFieldData={textFieldData} />
</TouchableOpacity>
) : (
<TextComponent textFieldData={textFieldData} />
);
};