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

Wrapped TextInput with editable set to false calls onFocus anyway #1384

Closed
TMaszko opened this issue Apr 12, 2023 · 4 comments · Fixed by #1385
Closed

Wrapped TextInput with editable set to false calls onFocus anyway #1384

TMaszko opened this issue Apr 12, 2023 · 4 comments · Fixed by #1385

Comments

@TMaszko
Copy link
Contributor

TMaszko commented Apr 12, 2023

Describe the bug

When fireEvent is called with wrapped TextInput(i.e with styled-components) that is disabled the event bubbles up.
For example: We want to check if the TextInput component is actually disabled we might check whether onFocus event handler was called or not.

Expected behaviour

onFocus handler should not be called if the TextInput is disabled (aka editable prop set to false)

Steps to Reproduce

https://github.com/TMaszko/FireEventBug
Install dependencies and run yarn test

Versions

npmPackages:
@testing-library/react-native: ^12.0.1 => 12.0.1
react: 18.2.0 => 18.2.0
react-native: 0.71.6 => 0.71.6
react-test-renderer: ^18.2.0 => 18.2.0

@pierrezimmermannbam
Copy link
Collaborator

Hello @TMaszko, this happens because the component that wraps the TextInput also has an onFocus prop and since it's not a TextInput from React Native the check on enabled prop is not done. This issue is a duplicate of #1261 so I think we can close this one and continue the discussion on the other issue

@TMaszko
Copy link
Contributor Author

TMaszko commented Apr 13, 2023

Hi @pierrezimmermannbam I know that but touch responder will have this prop so we can do the additional check like I did in #1385

@mdjastrzebski mdjastrzebski reopened this Apr 24, 2023
@mdjastrzebski
Copy link
Member

Duplicate of #1261

@mdjastrzebski mdjastrzebski marked this as a duplicate of #1261 Apr 24, 2023
@mdjastrzebski mdjastrzebski closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2023
@mdjastrzebski
Copy link
Member

This issue has been resolved in v12.1.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants