Skip to content

Fix iOS text input not working with password integration #11845

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/video/uikit/SDL_uikitviewcontroller.m
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,14 @@ - (void)keyboardDidHide:(NSNotification *)notification

- (void)textFieldTextDidChange:(NSNotification *)notification
{
// When opening a password manager overlay to select a password and have it auto-filled,
// text input becomes stopped as a result of the keyboard being hidden or the text field losing focus.
// As a workaround, ensure text input is activated on any changes to the text field.
bool startTextInputMomentarily = !SDL_TextInputActive(window);

if (startTextInputMomentarily)
SDL_StartTextInput(window);

if (textField.markedTextRange == nil) {
NSUInteger compareLength = SDL_min(textField.text.length, committedText.length);
NSUInteger matchLength;
Expand Down Expand Up @@ -612,6 +620,9 @@ - (void)textFieldTextDidChange:(NSNotification *)notification
}
committedText = textField.text;
}

if (startTextInputMomentarily)
SDL_StopTextInput(window);
}

- (void)updateKeyboard
Expand Down Expand Up @@ -657,7 +668,7 @@ - (void)setKeyboardHeight:(int)height
- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField.markedTextRange == nil) {
if (textField.text.length < 16) {
if ([string length] == 0 && textField.text.length < 16) {
[self resetTextState];
}
}
Expand Down
Loading