Skip to content

[web] handle common props in virtual detector#3982

Merged
akwasniewski merged 10 commits into
mainfrom
@akwasniewski/web-handle-common-props-virtual-detector
Feb 24, 2026
Merged

[web] handle common props in virtual detector#3982
akwasniewski merged 10 commits into
mainfrom
@akwasniewski/web-handle-common-props-virtual-detector

Conversation

@akwasniewski
Copy link
Copy Markdown
Contributor

Description

Common web-only props enableContextMenu, touchAction, userSelect were not properly handled inside virtual detector. This PR fixes it.

Test plan

Tested on the following example

Details
import { COLORS, commonStyles, Feedback } from '../common-app/src/common';
import React, { useRef } from 'react';
import { View } from 'react-native';
import {
  InterceptingGestureDetector,
  useTapGesture,
  VirtualGestureDetector,
} from 'react-native-gesture-handler';
import Svg, { Circle, Rect } from 'react-native-svg';

export default function LogicDetectorExample() {
  const feedbackRef = useRef<{ showMessage: (msg: string) => void }>(null);

  const circleElementTap = useTapGesture({
    onActivate: () => {
      feedbackRef.current?.showMessage('Tapped circle!');
    },
    disableReanimated: true,
  });

  const rectElementTap = useTapGesture({
    onActivate: () => {
      feedbackRef.current?.showMessage('Tapped parallelogram!');
    },
    disableReanimated: true,
  });

  const containerTap = useTapGesture({
    onActivate: () => {
      feedbackRef.current?.showMessage('Tapped container!');
    },
    disableReanimated: true,
  });

  // onPress must be set to enable gesture recognition on svg
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  const noop = () => { };

  return (
    <View style={commonStyles.centerView}>
      <InterceptingGestureDetector gesture={containerTap}>
        <Svg
          height="250"
          width="250"
          style={{ backgroundColor: COLORS.PURPLE }}>
          <VirtualGestureDetector gesture={circleElementTap}>
            <Circle
              cx="125"
              cy="125"
              r="125"
              fill={COLORS.NAVY}
              onPress={noop}
            />
          </VirtualGestureDetector>
          <VirtualGestureDetector enableContextMenu={true} gesture={rectElementTap}>
            <Rect
              skewX="45"
              width="125"
              height="250"
              fill={COLORS.KINDA_BLUE}
              onPress={noop}
            />
          </VirtualGestureDetector>
        </Svg>
      </InterceptingGestureDetector>
      <Feedback ref={feedbackRef} />
    </View>
  );
}

Copilot AI review requested due to automatic review settings February 18, 2026 10:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes propagation of common web-only DOM props (enableContextMenu, touchAction, userSelect) through the v3 “virtual detector” path so they can be applied to virtual children/handlers on web.

Changes:

  • Extends virtual detector props/types to carry userSelect, touchAction, and enableContextMenu.
  • Passes these props from VirtualDetector → intercepting context → web host detector.
  • Updates the web host detector to apply per-virtual-child DOM config to the attached virtual handler tags.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts Adds DOM-prop fields to VirtualChild so intercepting/host layers can receive them.
packages/react-native-gesture-handler/src/v3/detectors/common.ts Makes VirtualDetectorProps include common detector props (web-only DOM props).
packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx Plumbs DOM props into the registered VirtualChild and updates effect deps.
packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx Includes DOM props when mapping virtual children on web before passing to host detector.
packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx Applies per-virtual-child DOM config via updateGestureHandlerConfig for virtual handler tags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/react-native-gesture-handler/src/v3/detectors/common.ts Outdated
Comment thread packages/react-native-gesture-handler/src/v3/types/DetectorTypes.ts
akwasniewski and others added 2 commits February 23, 2026 08:15
…tureDetector.web.tsx

Co-authored-by: Michał Bert <63123542+m-bert@users.noreply.github.com>
Andrzej Antoni Kwaśniewski added 2 commits February 23, 2026 10:27
@akwasniewski akwasniewski merged commit 4285b4f into main Feb 24, 2026
3 checks passed
@akwasniewski akwasniewski deleted the @akwasniewski/web-handle-common-props-virtual-detector branch February 24, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants