Fix iOS text input not working with password integration #11845
+12
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Work around password integrations hiding software keyboard and preventing autofill
When pressing the "Passwords" button on the keyboard to pick a password from the 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.My previous attempt in #11699 and also the attempt of using
textFieldDidEndEditing
both do not work most of the time. For some reason, when the password integration overlay opens, and the user taps the search bar to search for their password, the SDL text field becomes unfocused and thetextFieldDidEndEditing
gets triggered, without being accompanied with atextFieldDidBeginEditing
or the text field gaining focus again. Therefore the text input state becomes deactivated at the point of searching and is never activated back, ignoring any password selected for auto-fill.As a last resort, this PR makes the assumption that any changes to the text field content could not have happened without the user having text input already active, and so it forcibly activates text input in
textFieldTextDidChange
momentarily until all relevant text input events are sent out to the game, then text input is disabled again.