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

TouchableWithoutFeedback not working with flexbox #864

Closed
lucastonon opened this issue Dec 4, 2019 · 14 comments
Closed

TouchableWithoutFeedback not working with flexbox #864

lucastonon opened this issue Dec 4, 2019 · 14 comments
Labels
Area: Touchable BugBash 31.03 Important This seem to be a serious issue and we will need to take a deeper look into it some time soon

Comments

@lucastonon
Copy link

I am having some trouble showing {children} when using this setup.
If I use react-native's TouchableWithoutFeedback it works. But when I import TouchableWithoutFeedback from react-native-gesture-handler it does not show my {children}.
And react-native's touchable blocks the view responder events, and I need to be receiving both. Do you guys have any idea what's wrong?

`

        <View style={{flex: 1, backgroundColor: 'black'}}>

            <View style={{flexGrow: 1}}
                  onStartShouldSetResponder={() => true}
                  onResponderRelease={(event) => this.handleResponderRelease(event)}>

                <TouchableWithoutFeedback
                    onPressIn={this.handlePressIn}
                    delayPressIn={20}
                    delayPressOut={30}
                    onPressOut={this.handlePressOut}>
                    <View style={{flex: 1}}>
                        {children}
                    </View>
                </TouchableWithoutFeedback>

            </View>

            <View style={{height: 90}}>
                <FlatList
                    ...

                    />
            </View>
        </View>`
@panda6412
Copy link

Also same here.

@lestarcdog
Copy link

lestarcdog commented Aug 10, 2020

You can try to use height instead of flex on the <TouchableWithoutFeedback style={{height: '100%'}}>

@jakub-gonet jakub-gonet added Important This seem to be a serious issue and we will need to take a deeper look into it some time soon Area: Touchable labels Sep 3, 2020
@pribeh
Copy link

pribeh commented Sep 18, 2020

Flex doesn't seem to work at all inside Touchables.

@uragecz
Copy link

uragecz commented Nov 11, 2020

Wondering why there is no any reaction on this topic??! It's critical problem.. having same issue with TouchableOpacity.. if i use TouchableOpacity from react-native libary then everything works well

@andychikhany
Copy link

andychikhany commented Nov 12, 2020

wrap the touchable that you are getting from gesture handler with a /View/ and apply the styling to the view it should work

@guiled
Copy link

guiled commented Nov 13, 2020

Got to debug few hours to figure this out !

@chybisov
Copy link

chybisov commented Dec 3, 2020

@jakub-gonet could you please look into this? It's really frustrating. I also have this issue and only fix I see is to switch to standard react-native TouchableWithoutFeedback, but what is the purpose then 😃

@Avrmaster
Copy link

Still experiencing this problem with TouchableNativeFeedback
Using "react-native-gesture-handler": "^1.7.0"

@luizwhite
Copy link

luizwhite commented Apr 2, 2021

Same issue here..

Tested with
"react-native-gesture-handler": "^1.10.3"

With height: '100%' it works, but have to check on iOS

@pribeh
Copy link

pribeh commented Apr 2, 2021

Didn't realize a whole bunch of buttons weren't working on android because of this again. Any chance someone could take a look at this?

@teodorrd27
Copy link

teodorrd27 commented Apr 14, 2021

Really don't mean to distract from the issue at hand which is still an issue. But, I've managed to use
<Pressable style={{width: '100%'}}>{children}</Pressable>
successfully with flexbox for a full width container that behaves as you'd expect.
I think they're quietly trying to transition to Pressable regardless, it's all over the touch objects in the docs.

@j-piasecki
Copy link
Member

The issue comes from the way touchables are implemented. Basically they are composed of two views: BaseButton for handling events and Animated.View that animates and displays children. As a workaround you can use containerStyle and style props of the touchable components (that style BaseButton and Animated.View respectively).
In case of the example from the description, I think that adding

  containerStyle={{ flex: 1 }}
  style={{ flex: 1 }}

props to the TouchableWithoutFeedback would solve the problem.

@WoLewicki
Copy link
Member

Since the above comment explains how it works under the hood, I think we can close this issue. Feel free to comment if you have any questions and we can always reopen it.

@Daumis102
Copy link

While the proposed solution works, the "containerStyle" attribute is not added to the TouchableWithoutFeedback Props, showing an annoying error in IDE:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Touchable BugBash 31.03 Important This seem to be a serious issue and we will need to take a deeper look into it some time soon
Projects
None yet
Development

No branches or pull requests