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

InputAccessoryView in a FlatList - onPress not firing #23899

Closed
mccabemj opened this issue Mar 13, 2019 · 2 comments
Closed

InputAccessoryView in a FlatList - onPress not firing #23899

mccabemj opened this issue Mar 13, 2019 · 2 comments
Labels
Bug Component: FlatList Component: InputAccessoryView Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@mccabemj
Copy link

mccabemj commented Mar 13, 2019

🐛 Bug Report

I have a working InputAccessoryView within a View. I have set the nativeID to match the TextInput which calls it. This works.

In my case, I have multiple TextInputs rendered in a FlatList. What I need is a generic set of buttons above the keyboard, which when pressed, enters that text into the TextInput which called it.

The way I imagined this working is to have a InputAccessoryView inside each rendered item in my FlatList. This would mean I could have the info of each TextViews state value, and upon pressing one of these generic buttons in my InputAccessoryView, I'd have my current rendered items state and modify it.

However, the issue I have is that no onPress events are firing when InputAccessoryView is inside a rendered item of the FlatList.

Instead of firing any onPress events, it instead just closes the keyboard. Note, even simply putting alert('something') does not fire

To Reproduce

I don't have a working demo to show, but simply having a flat list with rendered items, each one containing a textbox (and unique value) and an InputAccessoryView

An example (written, not run, so not checked the syntax fully)

<FlatList
  data={this.state.myItems}
  renderItem={({item}) => this.renderItem(item)}
...


renderItem(item) {
  return (
    <View>
      <TextInput inputAccessoryViewId={item.id}></TextInput>
      <InputAccessoryView nativeID={item.id}>
        <Button onPress={this.updateItem} />
       </InputAccessoryView>
    </View>
  )
}

Expected Behavior

Expect the function (in the above example) to call this.updateItem but does not

Current Workaround

onFocus of the TextInput I set something like currentTextInput into state. I can then use this on press of the button in the InputAccessoryView. Seems a bit of a dodgy work around though

Environment

react: 16.6.3
react-native: 0.58.4
react-native-cli: 2.0.1

@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write `[skip envinfo]` alongside an explanation in your Environment: section.

@mccabemj mccabemj changed the title InputAccessoryView in a FlatList InputAccessoryView in a FlatList - onPress not firing Mar 13, 2019
@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Mar 21, 2019
@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not contain the necessary environment info, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 21, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: FlatList Component: InputAccessoryView Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants