Skip to content

[Native] Automatically unflatten detector children#3963

Open
j-piasecki wants to merge 1 commit intomainfrom
@jpiasecki/automatically-unflatten-children
Open

[Native] Automatically unflatten detector children#3963
j-piasecki wants to merge 1 commit intomainfrom
@jpiasecki/automatically-unflatten-children

Conversation

@j-piasecki
Copy link
Member

Description

On Android this requires #3962 to test, as the non-transparent views are never flattened.

Automatically unflattens the child node of the detector component, so that setting collapsable={false} is no longer needed.

Test plan

Notce the lack of collapsable={false} on the detector's child.

import React from 'react';
import { StyleSheet, View } from 'react-native';
import {
  GestureDetector,
  GestureHandlerRootView,
  useTapGesture,
} from 'react-native-gesture-handler';

export default function EmptyExample() {
  const tap = useTapGesture({
    onActivate: () => {
      console.log('tap');
    },
  });

  return (
    <GestureHandlerRootView style={styles.container}>
      <GestureDetector gesture={tap}>
        <View style={{ flex: 1, backgroundColor: 'transparent' }} />
      </GestureDetector>
    </GestureHandlerRootView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

Copilot AI review requested due to automatic review settings February 6, 2026 14:33
Copy link
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

This PR modifies the React Native Gesture Handler's Detector shadow node to automatically unflatten its child component, eliminating the need for developers to manually set collapsable={false}. This works in conjunction with PR #3962, which ensures transparent views under the Detector are properly handled during hit testing.

Changes:

  • Override appendChild and replaceChild methods to automatically unflatten child nodes
  • Implement unflattenNode helper that sets FormsView and FormsStackingContext traits on children
  • Update initialization logic to use the new replaceChild override

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
RNGestureHandlerDetectorShadowNode.h Added method declarations for appendChild, replaceChild overrides and private unflattenNode helper
RNGestureHandlerDetectorShadowNode.cpp Implemented child unflattening logic by setting shadow node traits when children are added or replaced

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

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.

1 participant