Pressing Enter/Submit when the user focus is in the search creates a new line break rather than submitting the search.
This appears to only happen in an emulated environment with a physical keyboard.
The text input is androidx Jetpack Compose. I added the lines:
singleLine = true,
maxLines = 1,
to the OutlinedTextField, but all that did was prevent the textbox from expanding to the next line.
You can see in the screenshot below that the cursor moves to the next line. The cursor is there and is barely visible, but the only change was that the text field no longer expands to a second row:
Search works just fine with the on-screen keyboard, so that's not the issue. The issue only seems to be with external, physical keyboards.
Use an onQueryTextChanged on the searchView, and if you see a \n inserted delete it and trigger a search
Related
I have a very weird, but consistent bug in my app with any standard Android keyboard that supports word predictions.
What I’m doing is that I call InputMethodManager.restartInput() after I evaluated the input of an EditText to show a different IME label (I check the current text with a TextWatcher and the set the label to ”Close” when the text is empty and to “Send” when it's not). Without calling restartInput() the IME label change is not taken over until the connection is otherwise renewed, e.g. by closing and reopening the keyboard again.
Now when I manually enter characters through the keyboard everything is fine as expected, labels are changed, key strokes are accepted, all good, but if I click on one of the predictions on some keyboard to paste the word, the second click on the prediction is lost (i.e. the word that should be pasted after I called restartInput()).
"Lost" means different things for different keyboards, SwiftKey for example keeps the first word underlined and then replaces that with the second word on click, while Google's keyboard just keeps the first word, ignores the second word completely and then continues with any next word.
This video shows the issue: https://puu.sh/v0WUo/8f9b3571ed.mp4
I click on “Test and the”, but the EditText only receives “Test the".
Has anybody seen this before? What am I doing wrong?
Just found myself trying to figure out this strange behavior in for EditText.
Information:
Bug seems to only happen in some devices! for now I've only seen it in Sony Xperia D2303.
App description:
I'm working on an app that has a main activity and navigation is done trough different fragments that are replaced as user moves from one section to another.
At one point I'm showing a DialogFragment with an edit text field, with background set to #null, with a hint text. (I have also tried with a normal edit text, taken from widget list and dragged to the layout and found the same behavior).
Problem:
When clicking on the EditText, software keyboard SHOWS UP but when typing there is no letter input in the EditText! I can long press, to visualize cursor position marker and also the magnifying glass shows up.
Things I've tried:
- I've tried requesting focus with xml, programmatically.
- Setting touchable(in touch mode also)
- Setting descendantFocusability attribute of parent to 'afterDescendants'
- Overriding onTouchListener and showing keyboard programmatically through the InputManager and using the edit text's token
… and maybe other things which I don't remember
There is but a workaround that I've found!!! sending the app to background, and bringing it to foreground again… so it seems something related to focus maybe?? but then why does keyboard show up, and cursor marker and magnifying glass work?
This solution does not work for me as it depends on the user taking action
Has anyone found this problem? any suggestions?
Thanks in advance!
I have some html forms that when they get rendered I would like the keyboard to appear without the user having to touch the field first. I have tried using click and focus neither brings up the keyboard.
For what its worth I am using angular.
I do not believe this is possible with out a very kludgy work around. You might be able to have a hidden text field that it set to focus, which would bring up the keyboard and then manually set focus on other items in the view when needed. However this might cause some issues and you might be able to see the cursor in the hidden text field, among other issues. Why do you need the keyboard to be displayed without a focus on some field?
I am trying to set a Android EditText to be Multiline, and not display any suggestions.
textView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
However, this is just a single line. Currently pressing the enter/carriage return button hides the keyboard, instead of moving to a new line.
textView.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
Setting the IME flag causes the enter button to insert whitespace.
I need to display no suggestions and also have the EditText to be multiline. Am I missing something here?
I have solved this issue. I was using SwiftKey keyboard, swapping to the default Google keyboard seems to work perfectly. My guess is swiftkey doesn't have some of these methods implemented?
We observed a very strange bug with our app on the samsung s3 (running android 4.0.4 )
When typing text into a text area only the first character of each word would fill in, and only after you pressed space or picked a word from predictive text.
Typing 'what the hell ..' would result in 'w t h' being entered in the text area
Other text areas on different screens were working fine.
Turning off predictive text also fixed the issue.
Has anyone run into this issue before?
After further investigation we noticed that the problematic textarea wasn't changing appearance when it got focus - all our working text fields turned into square cornered fields with orange borders when clicked.
It turns out android does something odd and dynamically replaces your input fields with native elements as they get focus (hence the un-style-able orange bordered square bits :( ).
the kicker - if your input is inside an element with css absolute positioning this fails, and this also seems to mess up some forms of keyboard input. setting the element (and parent elements) to use position static fixes the issue.
We only saw this on the s3 when predictive text was on (this is the default..) but it may be on other devices.
Chalk this one up to Androids browser still being a mess..
Note that using this css hack to stop the native elements from being substituted:
input:focus { -webkit-user-modify: read-write-plaintext-only; }
caused ALL our text fields to have the problem outlined in this thread.
I had this problem too for a long time but have found that the key to stopping this glitch is to turn off the predictive text option in the keyboard settings every time you experience the 1st character input only problem. Personally, I like the predictive text being on 99% of the time, but some web pages (email providers mainly) aren't configured for predictive text to be used, so I keep predictive text on & just turn it off whenever I come across a web page where I experience the 1st character input only problem. To turn it on/off simply hit the cog button on the keyboard & where it says predictive text, just swipe the slider to the left, to the off position. This will allow whole words to be typed instead of just 1 character at a time. Then, once you've finished typing, you can hit the cog again & turn predictive text back on.