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

fix: unfocused TextInput label disappears on new architecture (#3776) #3899

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

osman-turan
Copy link
Contributor

Summary

The TextInput label disappears when the input is unfocused on React Native's New Architecture (on both Android and iOS). After some digging, I noticed the root cause is switching between an Animated.Value and some numbers depending on some booleans:

const placeholderOpacity = hasActiveOutline
  ? parentState.labeled // <-- `Animated.Value`
  : parentState.labelLayout.measured
  ? 1
  : 0;

If we switch between Animated.Value instances, the problem disappears:

const { current: placeholderOpacityAnims } = React.useRef([
  new Animated.Value(0),
  new Animated.Value(1),
]);

const placeholderOpacity = hasActiveOutline
  ? parentState.labeled
  : placeholderOpacityAnims[parentState.labelLayout.measured ? 1 : 0];

#3776 has more details about the issue and contains an example repo to reproduce it.

Test plan

https://github.com/ChrisGadek1/react-native-paper-textinput-bug-reproduction repo from #3776 (comment) can be used for testing this fix.

@callstack-bot
Copy link

Hey @osman-turan, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@archieWu
Copy link

archieWu commented Jul 4, 2023

This bug was fixed one month but has not been released in production

Copy link
Member

@lukewalczak lukewalczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for help! 🙌🏽

@lukewalczak lukewalczak merged commit 9d802f6 into callstack:main Sep 18, 2023
@osman-turan
Copy link
Contributor Author

@lukewalczak Thanks! 🙌

@archieWu Thanks for pointing out. But I tried some of the later releases after my PR, and none of them worked for me.

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

Successfully merging this pull request may close these issues.

4 participants