Textinput includes touchableopacity which supersedes parent onpress actions #23720
Labels
Bug
Component: TextInput
Related to the TextInput component.
Component: TouchableOpacity
Platform: Android
Android applications.
Resolution: Locked
This issue was locked by the bot.
🐛 Bug Report
When a textinput component is included as a child of touchableopacity, it supersedes the parent's touchableopacity onpress.
In some cases, we want to change the display of a textinput's parent when the textinput is pressed; this goes beyond using onfocus as if the textinput already has focus, the onfocus is correctly not invoked.
As a side note, if I have nested TouchableOpacity elements, even if the child element with TouchableOpacity does not have an onPress, it also supersedes the parent's onPress. Just something interesting to note.
To Reproduce
Nest a textinput component within a touchableopacity component.
The OnPress of the touchableopacity is never called.
In inspecting the TextInput element, this is caused by the fact that textinput is always wrapped in its own TouchableOpacity with OnPress logic. From what I can tell, this logic is necessary to update the onfocus of the textinput.
Note, this issue was previously reported with https://github.com/facebook/react-native/issues/14958 but that item was closed as stale.
Expected Behavior
Ideally, an OnPress could be added to the textinput component to be invoked prior (or after) setting the onfocus event (of course, with code added above this to pass in the onPress prop as well):
TextInput.js
Code Example
Environment
React Native Environment Info:
The text was updated successfully, but these errors were encountered: