From 4d3b0bc6698193dfcbbe4392dced439b0a255dcc Mon Sep 17 00:00:00 2001 From: Frederick O'Brien Date: Thu, 19 Jun 2025 17:53:43 +0100 Subject: [PATCH 1/2] Rejig interactives `disableArticleSwipe` implementation --- ...ractivesDisableArticleSwipe.importable.tsx | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx b/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx index c34983d2b98..52a2d3b5b8e 100644 --- a/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx +++ b/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx @@ -3,12 +3,31 @@ import { useEffect } from 'react'; import { getInteractionClient } from '../lib/bridgetApi'; export const InteractivesDisableArticleSwipe = () => { - useEffect(() => { - void getInteractionClient() + const onTouchStart = () => { + getInteractionClient() .disableArticleSwipe(true) .catch((error) => { - log('dotcom', 'disableArticleSwipe failed:', error); + log('dotcom', 'disableArticleSwipe(true) failed', error); + }); + }; + + const onTouchEnd = () => { + getInteractionClient() + .disableArticleSwipe(false) + .catch((error) => { + log('dotcom', 'disableArticleSwipe(false) failed', error); }); + }; + useEffect(() => { + document.addEventListener('touchstart', onTouchStart, { + passive: true, + }); + document.addEventListener('touchend', onTouchEnd, { passive: true }); + + return () => { + document.removeEventListener('touchstart', onTouchStart); + document.removeEventListener('touchend', onTouchEnd); + }; }, []); return null; }; From bd01f1cfbb0ea966d89c1c4d181d7d29f30738d8 Mon Sep 17 00:00:00 2001 From: Frederick O'Brien Date: Fri, 20 Jun 2025 10:11:28 +0100 Subject: [PATCH 2/2] Remove touchend parts --- .../InteractivesDisableArticleSwipe.importable.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx b/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx index 52a2d3b5b8e..9e867b20961 100644 --- a/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx +++ b/dotcom-rendering/src/components/InteractivesDisableArticleSwipe.importable.tsx @@ -7,26 +7,16 @@ export const InteractivesDisableArticleSwipe = () => { getInteractionClient() .disableArticleSwipe(true) .catch((error) => { - log('dotcom', 'disableArticleSwipe(true) failed', error); - }); - }; - - const onTouchEnd = () => { - getInteractionClient() - .disableArticleSwipe(false) - .catch((error) => { - log('dotcom', 'disableArticleSwipe(false) failed', error); + log('dotcom', 'disableArticleSwipe failed', error); }); }; useEffect(() => { document.addEventListener('touchstart', onTouchStart, { passive: true, }); - document.addEventListener('touchend', onTouchEnd, { passive: true }); return () => { document.removeEventListener('touchstart', onTouchStart); - document.removeEventListener('touchend', onTouchEnd); }; }, []); return null;