Skip to content
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

Fix iOS text input not working well with password auto-fill integration #11699

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

frenzibyte
Copy link
Contributor

This PR includes two separate fixes focusing towards the same goal, I'm not sure how to split them as they can't make sense on their own. My Objective-C coding skills are not that well so I apologise in advance if I made an idiotic mistake somewhere in the code 😅

Fix text field resetting text when replaced with a short string

When selecting a password to auto-fill in the current text field, the textField.text property is overwritten with that password, and if the password is less than 16 characters, it triggers the code that resets the text content and messes up the entire logic that is supposed to perform backspaces and such.

The fix is to simply reset the text (i.e. fill back the "obligatory for backspace" text) when the event is triggered with a string of length zero, i.e. when the user deletes characters (see docs).

The fix above can be argued to be more of a band-aid than a solid fix, as there's probably no better fix than to rewrite the iOS text input system from top to bottom and introduce text input events when a text is reset or replaced etc. It's a heavy one to discuss and my take on the matter may probably be biased towards iOS or not well thought of, but either way the fix above will do for now.

Associate text input state with the UITextField's focus state instead

When pressing the "Passwords" button on the keyboard to pick a keychain/vault, the keyboard hides, which triggers the keyboardWillHide animation, and incorrectly stop text input, ultimately not accepting any character entered from the selected password due to the text input being inactive.

That issue made me try to "think out of the box", and I've noticed that UIKit synchronises the text field's "is first responder" state when the user dismisses the keyboard or otherwise, and correctly maintains it when the user presses the "Passwords" button and picks a password, as well as also keeping the text field focused when connecting a hardware keyboard or changing orientation. So overall it was a better state to associate with SDL text input's state rather than the on-screen keyboard's visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant