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

[TextInput] secureTextEntry={true} causes text to flicker

Open mileung opened this issue 10 years ago • 14 comments

version 0.27.2

https://www.youtube.com/watch?v=9QwZQUVPTl4&feature=youtu.be

mileung avatar Jun 16 '16 05:06 mileung

I have the same issue. I believe this started happening in 0.26:

securetextentry1

ryankask avatar Jun 16 '16 12:06 ryankask

Same issue here since updating RN version to 0.27.1. Looks identical to above example

alekhurst avatar Jun 16 '16 17:06 alekhurst

same issue happening here on 0.26

alphasp avatar Jun 17 '16 13:06 alphasp

This is a duplicate of https://github.com/facebook/react-native/issues/7936.

@MiLeung Should this be closed so all attention can be focused on that issue?

ryankask avatar Jun 17 '16 22:06 ryankask

@ryankask I think #7936 is a slightly different issue. This issue shows the characters for a fraction of a second before obscuring it. #7936 immediately obscures the text.

mileung avatar Jun 18 '16 16:06 mileung

Good point. They seem very similar. The example code the other user posted is using setTimeout and I'm not sure if that's making it seem different.

On Saturday, 18 June 2016, Michael Leung [email protected] wrote:

@ryankask https://github.com/ryankask I think #7936 https://github.com/facebook/react-native/issues/7936 is a slightly different issue. This issue shows the characters for a fraction of a second before obscuring it. #7936 https://github.com/facebook/react-native/issues/7936 immediately obscures the text.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/8142#issuecomment-226951797, or mute the thread https://github.com/notifications/unsubscribe/AAE_43DG_iH0N0vsdNlvrG66MX9DVT1Tks5qNB6xgaJpZM4I3B6V .

ryankask avatar Jun 19 '16 16:06 ryankask

@ryankask Indeed, #7936 used setTimeout, because the issue wasn't reproducible on rnplay.org without setTimeout.

In my codebase saving the value to component state and reading it back was not enough to cause the flicker, while using Redux store and action was enough.

One of the comments in #7936 is

I've been having this issue too, even just in setting the state of the current component and reading it back into the input.

So, it seems that this issue involves some race condition, and is not always reproducible when delay between user input and updating TextInput 'value' property is small.

sesm avatar Jun 28 '16 11:06 sesm

The workaround for me was using the TextInput defaultValue property instead of value. This way the input is populated at the beginning with a value from redux state, you can still trigger state changes in onChangeText event, everything behaves as expected and the error doesn't appear.

jakpaw avatar Jun 30 '16 14:06 jakpaw

can confirm @jakpaw 's workaround works.

KishPatel1996 avatar Jun 30 '16 15:06 KishPatel1996

@jakpaw No flicker, but the text still jumps slightly down for me

mileung avatar Jun 30 '16 15:06 mileung

@MiLeung same with me, but this is the best solution i've seen so far besides introducing a custom component.

KishPatel1996 avatar Jun 30 '16 21:06 KishPatel1996

@MiLeung It does, but I'd say it's an unrelated issue. It occurs already on RN 0.20: https://rnplay.org/apps/eSCk_Q

jakpaw avatar Jul 01 '16 08:07 jakpaw

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/textinput-securetextentrytrue-causes-text-to-flicker

Product Pains has been very useful in highlighting the top bugs and feature requests: https://productpains.com/product/react-native?tab=top

Also, if this issue is a bug, please consider sending a pull request with a fix.

mkonicek avatar Oct 27 '16 22:10 mkonicek

Same issue on iOS 9.3.5. Tried @jakpaw 's solution, but with no luck! iOS devices above 10 work fine

jamessawyer avatar Jun 25 '18 07:06 jamessawyer