-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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? |
|
It should not be closed! |
It works even worse on iOS 18 (beta 8) 😕 |
Are we the only persons in the world with this issue ? I don't understand why this flickering is not coming up on other apps? And why the simulator doesn't show the flickering ? iOS 17 is widely used right now. Can't ignore this. |
Try adding autoCorrect={false} to TextInput |
Hate the .textContentType(.oneTimeCode) "fix". Any update? |
I sometimes observe that problem in other apps so I guess there is something wrong with iOS. Hope iOS 18 will resolve the problems. |
I'm not sure #39411 (comment) |
Thanks! Helped in my case - I have email textInput with autoComplete set to username. Flickering is gone 👍 |
@artiemez Would you mind pasting your (Testing on iPhone 13 Pro with iOS 18) |
<Input
size="lg"
className="text-center"
label="email address"
enterKeyHint="next"
onSubmitEditing={handleSubmit}
placeholder="email address"
autoCapitalize="none"
autoComplete="username"
keyboardType="email-address"
autoCorrect={false}
showClearButton
{...field}
/>
|
I have the same problem with keyboardType="phone-pad" and autoComplete="tel" |
I was able to fix it by using what @artiemez proposed, but it's important to note that this only worked when using react-hook-form. I.e. using |
Could you please specify which apps you encountered the same issue in? |
Same issue here |
In my case add |
Has anyone discovered a good solution to this issue. In my Login/SignUp screens here are my Input Fields:
` Keep in mind that the keyboard only flickers when the email text input is changed, not the password. |
I found this guys post on stackoverflow and it solved it for me. Simply adding |
in iOS 18.2 this is resolved. edit: in iOS 18.2 the flickering is gone, apple fixed it with not closing the bar above the keyboard @Engazan |
It will be never resolved, use expo dom component and html input inside it (it's Webview but working rlly good) Yea it sound crazy but its only working solution cuz React team does not want to fix it :/ Also why never ? Cuz it's 1 year and still no progress, even flutter fixed it ... it's kinda sad |
@Engazan I'm curious to see how Flutter fixes it. Do you have any links? From my experience, even SwiftUI inputs have this keyboard issue which is really annoying. |
I'm running 18.3 and can confirm that the issue still exists. |
But then you lose the ability to autofill the password. |
Not sure if the fix will be this simple for everyone, but in my case just removing the value={email} and defaultValue={email} props fixed everything and allowed me to keep textContentType={'emailAddress'} and the 'Passwords' autofill button iOS provides. Tested on 18.2 simulator and 18.3.1 physical device, Expo 51, react-native 0.74.5. Some of you may need the value prop for your use case, but if you don't, consider trying without. |
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: