Skip to content

Commit af84d0b

Browse files
committed
fix(predict): reset dismissedViaBackRef on mount to prevent stale back-button state
1 parent 4585d39 commit af84d0b

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

app/components/UI/Predict/views/PredictBuyPreview/PredictBuyPreview.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,5 +2600,21 @@ describe('PredictBuyPreview', () => {
26002600

26012601
expect(trackBetslipDismissed).not.toHaveBeenCalled();
26022602
});
2603+
2604+
it('resets dismissedViaBackRef on mount so a previous back-button session does not bleed into next swipe', () => {
2605+
// Simulate a stale true value left over from a previous session
2606+
predictBuyPreviewDismissedViaBackRef.current = true;
2607+
2608+
renderWithProvider(<PredictBuyPreview />, { state: initialState });
2609+
2610+
// ref should be cleared on mount — swipe dismissal must not be misclassified
2611+
mockBeforeRemoveCallback?.();
2612+
2613+
expect(trackBetslipDismissed).toHaveBeenCalledWith(
2614+
expect.objectContaining({
2615+
dismissalMethod: PredictDismissalMethod.SWIPE,
2616+
}),
2617+
);
2618+
});
26032619
});
26042620
});

app/components/UI/Predict/views/PredictBuyPreview/PredictBuyPreview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const PredictBuyPreview = (props: PredictBuyPreviewProps) => {
117117
predictBuyPreviewSessionRef.mountTimestamp = mountTimestampRef.current;
118118
predictBuyPreviewSessionRef.hadEnteredAmount = false;
119119
predictBuyPreviewOrderInitiatedRef.current = false;
120+
predictBuyPreviewDismissedViaBackRef.current = false;
120121
return () => {
121122
predictBuyPreviewSessionRef.hadEnteredAmount = false;
122123
};

0 commit comments

Comments
 (0)