Autocompletion makes TextInput working abnormally after deleting characters or changing suggestions
Software Versions
- Python: 3.11.5
- OS: Android 12.0
- Kivy: 2.3.0/2.3.1
- Kivy installation method: Buildozer (all settings default)
Describe the bug
On Android, when entering text into the TextInputwidget, with autocompletion enabled in your keyboard, after a few selections and/or deletions of suggested words or simply deleting previously entered words or characters, the text input becomes random and chaotic: typed characters appear not in the position of the cursor, and the user can't either write or delete what they need. The whole TextInput field turns into complete gibberish.
This problem instantly disappears if you just close (unfocus) and then open (focus) the field again. Then you can again type normally - until the bug appears next time, which is almost inevitable if you write a relatively long text and use autocompletion actively.
This behavior is only present when autocompletion is on. If you disable autocompletion in the keyboard settings or make input_type = 'null' in your TextInput properties, the issue is absent. So this is somehow connected with the way Kivy (SDL?) processes autocompletion, especially when you press backspace or use a different autocompleted suggestion than you typed manually.
Expected behavior
TextInput should allow the user to type what they want correctly at all times, using autocompletion if it's on.
To Reproduce
There are various ways how this bug appears, the easiest way is typing some word incorrectly and then click on the suggested word which would be correct, and do this a few times. For example: type "I wanr", then click on "want" in the suggested words. Repeat 2-3 times. Then you will see that the input is broken: letters appear in wrong positions, and when you click backspace, they are deleted in wrong positions too. You actually can't type anything anymore.
Code and Logs and screenshots
I observe this bug in the simplest possible app with TextInput using the default, non-edited buildozer.spec file, generated as is.
Here is my code:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
class MyApp(App):
def build(self):
layout = BoxLayout()
text_input = TextInput(multiline=True, input_type="text")
layout.add_widget(text_input)
return layout
if __name__ == '__main__':
MyApp().run()As you can see from the screenshot below, instead of "want", "wat r" appears:
After this point, you can't type anything properly anymore.
See my video on YouTube where I reproduce this scenario using the aforementioned code, where I type "wanr/want" 2 times. In the end, the whole text becomes totally broken in multiple unexpected positions: https://youtube.com/shorts/uayo6GTt5ag?feature=share.
(If you can't access the YouTube link, use this alternative OneDrive link: SVID_20250929_092344_1.mp4.)
Additional context
My device is Huawei P20, but I received reports about this issue from numerous users from various countries, since it appears in my app on Google Play Store.
I've observed this issue since 2022 and very surprised it hasn't been addressed for such a long time, even after a few Kivy updates. I think it's a major issue: you can't work with text normally in Kivy apps, at least with autocompletion. A lot of my users are confused, many of them deleted the app because they just can't work. I look forward when it will be finally fixed.
Source: kivy/kivy