react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

TextInput label jumps to the center after rendered

Open brunohkbx opened this issue 6 years ago • 16 comments

Environment

"expo": "^36.0.0", "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz", "react-native-paper": "^3.8.0",

Description

It's been a while since I noticed this weird behavior when the TextInput is rendered, I think no one still has reported though. The label jumps when the TextInput is mounted, maybe because of some calculation. This behavior is more noticeable when moving between screens.

Reproducible Demo

https://snack.expo.io/@bruno.castro/b4fedd

  1. Run this snack on your phone ( is more noticeable )
  2. Click on the button 'Create account'
  3. Notice how the label 'Email' jumps to the center of the TextInput

Slowed Gif ezgif com-video-to-gif

brunohkbx avatar Feb 06 '20 01:02 brunohkbx

cc @jbinda

brunohkbx avatar Feb 06 '20 01:02 brunohkbx

Hi I have same problem

jonathanmachado avatar Feb 22 '20 23:02 jonathanmachado

only android

jonathanmachado avatar Feb 22 '20 23:02 jonathanmachado

I have the same issue Positions are computed with onLayout callback of Text component.

Label is hidden until measures are retrieved. But there are some extra conditions that don't work for outlined Textinput

In InputLabel.tsx the rule for opacity is parentState.value || parentState.focused ? parentState.labelLayout.measured ? 1 : 0 : 1,

Maybe the following is enough. With this instead of having a translation, the label pops up which is better from my point of view. parentState.labelLayout.measured ? 1 : 0

boulgom avatar Apr 05 '20 10:04 boulgom

I also have the same problem.

iberatkaya avatar Apr 08 '20 20:04 iberatkaya

I just update the snack. don't know why it broke. cc @jbinda

brunohkbx avatar Apr 24 '20 12:04 brunohkbx

@brunohkbx thanks will investigate on it soon

jbinda avatar Apr 24 '20 12:04 jbinda

Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

github-actions[bot] avatar Jun 24 '20 00:06 github-actions[bot]

I think the best fix for this would be to wait to show the label until label.Layout.measured is true, as @boulgom said:

[...] instead of having a translation, the label pops up which is better from my point of view. parentState.labelLayout.measured ? 1 : 0

However, in order to make a smoother effect, a fadeIn animation of 100ms should be added. I have done this in my own project, and am happy to submit a pull request for the modified InputLabel component.

I'm only going to do this, though, if it will be checked and looked at, as there are quite a few pull requests to this repo (mine included) that have been sitting ignored for some time. I don't mind, and I'd love to make a PR, but only if it will be used!

Let me know if one would be useful.

finnmerlett avatar Jul 08 '20 15:07 finnmerlett

@finnmerlett it would be really nice if you open a pull request to fix this issue. I'm still facing this but couldn't have time to work on a fix.

We can ask @jbinda to review your PR when you open. :smiley:

brunohkbx avatar Jul 08 '20 19:07 brunohkbx

@finnmerlett PR are more than welcome. If you have working solution to fix described issue feel free to open PR and attach me to review

jbinda avatar Jul 08 '20 22:07 jbinda

@brunohkbx @jbinda Sweet! Will see what I can do tomorrow

finnmerlett avatar Jul 08 '20 23:07 finnmerlett

Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

github-actions[bot] avatar Sep 07 '20 00:09 github-actions[bot]

Hey @finnmerlett. did you have the chance to work on this? If not, I'd like to work on this issue.

brunohkbx avatar Sep 07 '20 12:09 brunohkbx

I'm not sure if this is a regression or never really got fixed, but it's happening for me on 5.0.0-rc.3. Stacking a bunch of <TextInput/> components vertically shows that label updates cascade, resulting in the last ones getting laid-out with a significant delay. I got a layout latency of around 0.5s with just 11 stacked inputs.

jwueller avatar Jul 18 '22 21:07 jwueller

same here :( any solution?

"react-native-paper": "^5.13.1",
"react-native": "0.73.6",
"expo": "~50.0.19",

kauan777 avatar Mar 07 '25 11:03 kauan777