Skip to content
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

[Pressable] Nested Pressables don't behave as the ones from RN #2980

Closed
m-bert opened this issue Jul 4, 2024 · 0 comments · Fixed by #2981
Closed

[Pressable] Nested Pressables don't behave as the ones from RN #2980

m-bert opened this issue Jul 4, 2024 · 0 comments · Fixed by #2981
Assignees
Labels
Area: Pressable Maintainer issue Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web

Comments

@m-bert
Copy link
Contributor

m-bert commented Jul 4, 2024

Description

When you nest Pressables the inner one should activate. Right now you can see logs form both - inner and outer one.

Nagranie.z.ekranu.2024-07-4.o.10.20.02.mov

Steps to reproduce

Use the following code to test this issue:
import React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { Pressable as GHPressable } from 'react-native-gesture-handler';
import { Pressable as RNPRessable } from 'react-native';

const onPressCallback = (type: string) =>
  console.log(`${type} pressable onPress`);

const onPressInCallback = (type: string) =>
  console.log(`${type} pressable onPressIn`);

const onPressOutCallback = (type: string) =>
  console.log(`${type} pressable onPressOut`);

export default function App() {
  return (
    <View style={styles.container}>
      <View style={styles.innerContainer}>
        <Text style={styles.text}> Gesture Handler Pressable </Text>
        <GHPressable
          onPress={() => onPressCallback('outer')}
          onPressIn={() => onPressInCallback('outer')}
          onPressOut={() => onPressOutCallback('outer')}
          style={styles.outerPressable}>
          <GHPressable
            onPress={() => onPressCallback('inner')}
            onPressIn={() => onPressInCallback('inner')}
            onPressOut={() => onPressOutCallback('inner')}
            style={styles.innerPressable}
          />
        </GHPressable>
      </View>

      <View style={styles.innerContainer}>
        <Text style={styles.text}> React Native Pressable </Text>

        <RNPRessable
          onPress={() => onPressCallback('outer')}
          onPressIn={() => onPressInCallback('outer')}
          onPressOut={() => onPressOutCallback('outer')}
          style={styles.outerPressable}>
          <RNPRessable
            onPress={() => onPressCallback('inner')}
            onPressIn={() => onPressInCallback('inner')}
            onPressOut={() => onPressOutCallback('inner')}
            style={styles.innerPressable}
          />
        </RNPRessable>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'space-evenly',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },

  innerContainer: {
    display: 'flex',
    justifyContent: 'space-around',
    alignItems: 'center',
  },

  outerPressable: {
    width: 150,
    height: 150,
    backgroundColor: 'lightpink',

    display: 'flex',
    justifyContent: 'center',
    alignItems: 'center',
  },

  innerPressable: {
    width: 100,
    height: 100,
    backgroundColor: 'plum',
  },

  text: {
    fontSize: 16,
    margin: 20,
  },
});

Snack or a link to a repository

Irrelevant

Gesture Handler version

2.17.1

React Native version

0.74.1

Platforms

Android, iOS, Web

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@m-bert m-bert added Platform: Web Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Maintainer issue Area: Pressable labels Jul 4, 2024
latekvo added a commit that referenced this issue Jul 9, 2024
### References
closes: #2979
mentioned in: #2980

## Description
All styles given to Pressable are applied exclusively to the outer View
component.

## Test plan
Pull commit
[734c429](734c429)
to see the issue.
Pull commit
[36f1a24](36f1a24)
to see the same example with this issue resolved.

Both commits contain examples reproducing this issue under: 
`Example app > Release tests > Pressable Gesturization > Flex styling`.

In the commit [without a fix
applied](734c429),
you can see the square red shape used for presentation is misaligned
with it's parent, which is caused by inner box-model styles being
assigned to the outer `View` container.

This behaviour does on occur on the [fixed
commit](36f1a24).
@m-bert m-bert changed the title [Pressable] Nested Pressables doesn't behave as the ones from RN [Pressable] Nested Pressables don't behave as the ones from RN Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Pressable Maintainer issue Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants