Skip to content

Disable app article swipe on interactive atom blocks #14131

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import libDebounce from 'lodash.debounce';
import { useRef, useState } from 'react';
import { interactiveLegacyFigureClasses } from '../layouts/lib/interactiveLegacyStyling';
import { type ArticleFormat, ArticleSpecial } from '../lib/articleFormat';
import { getInteractionClient } from '../lib/bridgetApi';
import { useOnce } from '../lib/useOnce';
import { palette as themePalette } from '../palette';
import type { RoleType } from '../types/content';
Expand Down Expand Up @@ -349,6 +350,12 @@ export const InteractiveBlockComponent = ({
? true
: false;

const isApps = renderingTarget === 'Apps';

const onTouchStart = () => getInteractionClient().disableArticleSwipe(true);

const onTouchEnd = () => getInteractionClient().disableArticleSwipe(false);

useOnce(() => {
// We've brought the behavior from boot.js into this file to avoid loading 2 extra scripts

Expand Down Expand Up @@ -455,6 +462,8 @@ export const InteractiveBlockComponent = ({
data-alt={alt} // for compatibility with custom boot scripts
data-testid={`interactive-element-${encodeURI(alt ?? '')}`}
data-spacefinder-role={role}
onTouchStart={isApps ? onTouchStart : undefined}
onTouchEnd={isApps ? onTouchEnd : undefined}
>
{!loaded && (
<>
Expand Down