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

Property keyboardShouldPersistTaps={true} not working in <Modal /> view #10138

Closed
ogtfaber opened this issue Sep 27, 2016 · 21 comments
Closed

Property keyboardShouldPersistTaps={true} not working in <Modal /> view #10138

ogtfaber opened this issue Sep 27, 2016 · 21 comments
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@ogtfaber
Copy link

ogtfaber commented Sep 27, 2016

Issue Description

Given a in a , and the TextInput being active (keyboard is shown), I can't get any Touchable... element to respond to onPress before dismissing the keyboard.

Steps to Reproduce / Code Snippets

See the example code below. I would expect the TouchableOpacity (a yellow square) to popup an Alert while the TextInput is active and the keyboard is shown. Instead, I have to tap to dismiss the keyboard first.

The property keyboardShouldPersistTaps={true} does the trick in another view, but not inside of a

<Modal
  animationType={"slide"}
  transparent={false}
  visible={this.props.visible} >
  <ScrollView
    keyboardDismissMode="on-drag"
    keyboardShouldPersistTaps={true} >
    <TouchableOpacity onPress={() => alert(1)} style={{ backgroundColor: 'yellow', width: 200, height: 200, }} />
    <TextInput style={{
      height: 40,
      backgroundColor: 'red',
    }} />
  </ScrollView>
</Modal>

Additional Information

  • React Native version: 0.34
  • Platform(s): iOS
  • Operating System: macOS
@iljaiwjew
Copy link

iljaiwjew commented Sep 29, 2016

+1, 0.35.0-rc.0, iOS + macOS

@manggit
Copy link

manggit commented Nov 1, 2016

Same problem here, using a list view
0.36 iOS

@hlynn93
Copy link

hlynn93 commented Nov 4, 2016

+1 0.36 on iOS

@Arkanine
Copy link

Arkanine commented Dec 2, 2016

Have the same issue on iOS.
RN 0.32.1

@roysG
Copy link

roysG commented Dec 14, 2016

Same issue : react native - 0.37

@dcolin
Copy link

dcolin commented Jan 4, 2017

Same problem RN 0.39, any idea?

@chapati23
Copy link

confirmed, same issue. keyboardShouldPersisTaps has no effect on modals.
has anyone found a workaround for this by any chance?

@peter-tudosa
Copy link

I lost 2 hours because of this bug.

@kennethpdev
Copy link

I can confirm this is not working :/ using RN 0.41.1

@ptgamr
Copy link

ptgamr commented Feb 23, 2017

In my case, I have a ScrollView as the parent of Modal. Setting keyboardShouldPersistTaps on that ScrollView fix the issue inside Modal.

@dxiao
Copy link

dxiao commented Mar 8, 2017

putting the scrollview on the outside of my Modal did not solve issue for me.

@shergin shergin added the Platform: iOS iOS applications. label Mar 16, 2017
@despreston
Copy link

despreston commented Mar 31, 2017

+1

@andrzli
Copy link

andrzli commented Apr 14, 2017

Has anyone found a solution for this?

@iiitmahesh
Copy link

👍 Same issues

@despreston
Copy link

what fixed it for me is to make sure that all nested scrollviews have this property set.

e.g:

<ScrollView><ScrollView keyboardShouldPersistTaps></ScrollView></ScrollView>

This won't work because the parent ScrollView does not have this property set.

@gre
Copy link
Contributor

gre commented May 29, 2017

the fix for me was that I had to set keyboardShouldPersistTaps on ALL scrollview ancestors of my Modal...
otherwise, if any ScrollView in your parent tree do the default keyboardShouldPersistTaps="none", the keyboard will be dismissed (in my case I want to prevent a dismiss).

anyway, whatever what you want to solve (dismiss/not dismiss/respond to onPress) – you will have to be aware that the <Modal> cares about its (scrollview) parent stack, I assumed it would be like if rendered on top level, but no. rendering your modal component from root OR within a complex stack of scrollview, have different behavior. I think that's a valid concern for Modal to fix that, at least if not, it should be documented.

@marktrobinson
Copy link

@despreston & @gre that solved it for me.

Once my both my parent and child FlatList had the keyboardShouldPersistTaps prop set it worked a treat

@kakakalot
Copy link

I just use TouchableHighlight instead of TouchableOpacity and the onPress works

          <ScrollView
            keyboardShouldPersistTaps='always'
            style={styles.listItem}>
            {items.map((item, index) => this._renderTouchableItem(item, index))}
          </ScrollView>

  _renderTouchableItem = (item, index) => {
    return (
      <TouchableHighlight
        key={index}
        underlayColor='transparent'
        onPress={() => this.props.onTouchableItemSelected(this, index)}
      >
        <Text value={item.label} style={{ padding: 16, paddingLeft: 24 }} />
      </TouchableHighlight>
    )
  }

@hramos
Copy link
Contributor

hramos commented Aug 24, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Aug 24, 2017
@hramos hramos closed this as completed Aug 24, 2017
@profiVideos
Copy link

profiVideos commented Feb 5, 2018

I know this is closed. However, I just struggled with this for a few hours as well. Thanks to the comments read here; I found a solution that worked in my situation. I didn't even know that Flatlist would accept the keyboardShouldPersistTaps='always' parameter. I ended up having no extra ScrollViews, simply adding that parameter to Flatlist worked out great.

  <FlatList
    keyboardShouldPersistTaps='always'
    data={this.props.itemList}
    extraData={this.props}
    renderItem={this.renderCardItem}
    ItemSeparatorComponent={this.itemSeparator}
  />

Cheers
Using RN .51 BTW

@ghoshabhi
Copy link

The only solution I could find is having keyboardShouldPersistTaps on all ScrollViews in the component stack for the screen.

Credits: @despreston, @gre

@facebook facebook locked as resolved and limited conversation to collaborators Aug 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests