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
Keyboard Flickering on TextInput with secureTextEntry #39411
Comments
I also encountered the similar issue when in login screen |
I am experiencing the same on login screens. It's a newer issue. It seems to be caused by the suggested autofill. The problem is reduce by using default value prop passed to TextInput component that holds its own text ref and passes out ref value on change. |
I figured out the problemIt appears to be that at some point recently (pre iOS 17) a bug was introduced. Whenever This can be especially problematic for any RN apps using You can actually see the issue in native iOS apps:
For those who are using KeyboardAvoidingView (RN V0.72.* Patch Fix)For those who are wrapping their text inputs in a This isn't a pretty solution (and keep in mind it does not fix the root issue of the keyboard re-render), but you can do the following
be sure to set |
RPReplay-Final1696326197.movI began seeing this after updating the device i test on (iPhone 14 Pro) to iOS 17. Using Expo Go. Very annoying... What's interesting is that I am not experiencing this on another iPhone 11 Pro Max, also running iOS 17. |
I can confirm that it is an issue with the Passwords option in the Keyboard toolbar. Seems to be an issue across iOS 17 rather than a ReactNative issue. (It also isn't fixed in iOS 17.1, so we may be waiting a while for a fix). Closing as it isn't a React Native-specific issue. |
Adding |
@ThorANilsson I tried this, but it's not working for me. |
Here's what I did. TL;DR: If it's a password field, on each change update the actual string value in a map, and then render the value as bullets ( Somewhere created a file called export const maskMap = new Map<string, string>(); And in your custom import * as React from 'react';
import { TextInput } from 'react-native-paper';
import { maskMap } from './maskMap';
const PASSWORD_MASK_CHAR = '•';
. . .
// secureTextEntry determines whether or not this is a password field
const TextField = React.memo(({ onChange, secureTextEntry, ...props }: YourTextFieldProps) => {
const [textFieldId] = React.useState(uuid()); // use whatever uuid generator you'd like
. . .
React.useEffect(() => {
maskMap.set(textFieldId, '');
return () => {
maskMap.delete(textFieldId);
};
}, [secureTextEntry]);
const handleChange = React.useCallback((e: string) => {
if (secureTextEntry) {
const previousValue = maskMap.get(textFieldId) as string;
const formattedNewValue = e.replace(new RegExp(PASSWORD_MASK_CHAR, 'g'), '');
const newValue = previousValue + formattedNewValue;
onChange(newValue);
maskMap.set(textFieldId, previousValue + formattedNewValue);
} else {
onChange(e);
}
}, [secureTextEntry]);
const getValue = React.useCallback(() => {
if (!secureTextEntry) {
return value;
}
return value.replaceAll(/./g, PASSWORD_MASK_CHAR);
}, [value, secureTextEntry, showText, maskMap]);
. . .
return (
. . .
<TextInput
value={getValue()}
onChangeText={handleChange}
textContentType='none' // add this
. . .
/>
. . .
)
}) |
how this can be closed if its still happening ? it happends all the time when you have |
@Engazan It's closed because it's an iOS bug. iOS started over-triggering |
This works! Thank you!! Just saved my weekend lol |
Any updates |
Hi everyone, is there any update on this? |
Also happening on my side :) Seems to be an issue in flutter, too flutter/flutter#134723 |
I have problem also in android,, can somebody helpme? WhatsApp.Video.2024-02-06.at.03.17.54.mp4 |
How to hide the "password" panel on the keyboard when we use secureTextEntry? |
Hi there! On iOS lower version all works fine. |
The problem still exist on iOS 17.4 |
Can confirm this is happening on 17.4, on an email field for me, despite the type being
|
I've found in my case problem was caused by |
@Bialson, how do you manage the field's value in this case? I'm facing the same problem, and it is driving me crazy.
If I remove the prop Thanks in advance |
In addition to this flickering issue, it seems that in 17.4, when you try to tap a specific character in a TextInput to put the cursor at the middle of the string, it always jumps to the end of the RPReplay_Final1709793602.movIt even happens on the official react native demo (if you use the QR code to open in Expo): https://reactnative.dev/docs/textinput Is this also an iOS issue and not a RN issue @gcon97 |
If you add multline={true} to the email field that fixed it for me. So then I thought okay it's just to do with height, so I set a fixed height on both of my inputs, and the flickering when typing is gone but it still flickers when you change fields but I think that's because I have two different types of input. |
@loe-lobo You can declare reference to input and when needed use |
Try to add <TextInput
autoCorrect={false}
...
/> |
I have this issue on iPhone 17.3.1 |
|
The only solution that worked for me without negative effects, thanks. |
2024 and still using this workaround... |
@ThorANilsson solution worked for me. |
Has anyone found any solution for the keyboard to keep the password suggestion without flickering? |
Please check my above comment. One solution worked for me. Thanks |
@1989kumarsunil With textContentType="oneTimeCode" it partially solved the problem. The keyboard has stopped flickering, but the password suggestion is not being displayed. I want to keep the suggestion, as many users use password management applications and need this functionality... |
@matheuscostadesign From what I understand, there is no current solution that completely fixes the flickering problem. Above I have described a solution when in an avoiding view to stop view jumping, but it does not stop the flickering. This problem is the result of an iOS bug, but I will be looking into an updated temporary hack-fix soon. I will post the patch in here when it is complete. |
Is this problem exist in new major version 73.X, 74.X? |
not working on iOS 17+ |
Uploading Screen-recording-20240501-122505.mp4… |
Thanks @ThorANilsson |
Btw with iOS 17.5 and expo SDK 51 I don't see this issue in my apps ( they are gone ) |
Description
If you have 2 text inputs, (One with secure text entry enabled and the other set to disabled), When typing, highlighting and scrolling in the non-secure text entry, the keyboard will flicker.
This is an iOS issue only, I have tested this using iOS 17, on an iPhone 13 mini. I cannot repeat this issue in the simulator, only on the device.
It appears to be when iOS recognizes it as a login field, so it presents the auto-fill passwords UI. See the attached video on the flickering issue described.
RPReplay_Final1694522683.mov
React Native Version
0.72.4
Output of
npx react-native info
System:
OS: macOS 13.4.1
CPU: (10) arm64 Apple M1 Pro
Memory: 115.16 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.3.1
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.19
path: /usr/local/bin/yarn
npm:
version: 9.6.7
path: /opt/homebrew/bin/npm
Watchman:
version: 2023.06.12.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.11.3
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 22.4
- iOS 16.4
- macOS 13.3
- tvOS 16.4
- watchOS 9.4
Android SDK:
API Levels:
- "28"
- "31"
- "32"
- "33"
Build Tools:
- 30.0.2
- 30.0.3
- 32.0.0
- 33.0.0
- 34.0.0
System Images:
- android-30 | Google Play ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
- android-33 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9619390
Xcode:
version: 14.3.1/14E300b
path: /usr/bin/xcodebuild
Languages:
Java:
version: 18.0.1.1
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.4
wanted: 0.72.4
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Steps to reproduce
Have 2 TextInput components inside a view, one set with secureTextEntry, one without.
This issue is only seen on device, not in simulator
Snack, screenshot, or link to a repository
https://github.com/gcon97/KeyboardFlickeringDemo
The text was updated successfully, but these errors were encountered: