Skip to content

Backspace not fired when cursor after item in Chrome for Android #113

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

Closed
waddlesplash opened this issue Sep 14, 2013 · 20 comments
Closed

Backspace not fired when cursor after item in Chrome for Android #113

waddlesplash opened this issue Sep 14, 2013 · 20 comments

Comments

@waddlesplash
Copy link

waddlesplash commented Sep 14, 2013

(@joallard edit: 0. Use Google stock keyboard)

  1. Go to http://brianreavis.github.io/selectize.js/ in Chrome for Android.
  2. Attempt to backspace in the first example -- it won't work. Firefox for Android works as expected with backspace.

This happens for me on:
Android 4.3, Nexus 7 (build JWR66Y), Chrome 29 [latest stable].

If you need any more info, please let me know.

@brianreavis
Copy link
Member

Thanks for the report! It works on Mobile Chrome for iOS. I'm downloading an Android Emulator... I'll try to reproduce it and get it fixed.

@waddlesplash
Copy link
Author

Android-x86 won't work -- Chrome only runs on Android for ARM, so you'll have to use QEMU.

@brianreavis
Copy link
Member

Reproduced it. After some research, it seems to be an issue with Android itself at the OS level and it affects a number of other libraries. Backspace events are simply not fired when an input is empty. Take a look at:

Fixing this is going to be an ugly hack.

@kpwebb
Copy link

kpwebb commented Sep 19, 2013

What about making the remove plugin work for single select lists too? That way at least there's a way to clear the items even when backspace isn't working.

@mrjoelkemp
Copy link

FWIW, the version of Codemirror in this project works fine (backspace working) on Android (I'm running a nexus 4): https://code.google.com/p/codemirror-android/source/browse/assets/codemirror2/lib/codemirror.js

@loop0
Copy link

loop0 commented Mar 26, 2014

I'm having the same issue here, using selectize 0.9.0 on my Nexus 4 Android 4.4.2

@andreapavoni
Copy link

Hi all, I've found a quick and dirty solution for this issue, it seems to work decently as a workaround:

onDropdownOpen: function() {
      var userAgent = navigator.userAgent.toLowerCase();
      var isAndroid = userAgent.indexOf("android") > -1;
      if (isAndroid) {
        this.clear(); // 'this' refers to selectize object
      }
}

@gczh
Copy link

gczh commented Jul 11, 2014

@apeacox thanks for the quick and dirty fix! works just fine though anyone attempting this, be warned that the behaviour will differ slightly for iOS and android when trying to backspace -- tapping on the select will clear the selection on android.

@andreapavoni
Copy link

@gczh yeah, my fault not specifying it: more than a solution, it's a workaround to gracefully degrade on android devices.

@gustavohenke
Copy link

To those looking into this issue, Chrome Mobile will be fixed in the next release (which may occur in october 2014).

@leesalminen
Copy link

This seems to be fixed now to me. Close?

@bratanon
Copy link

Im still having this issue.

@rasmuscnielsen
Copy link

Just updated to 6.01 on Sony Xperia, and I'm also still experiencing the issue.

@joallard
Copy link
Member

I see the need, but that's not an easy one. Anyone has a reasonable solution?

@rasmuscnielsen
Copy link

@joallard I made this workaround on the angular-selectize directive: machineboy2045/angular-selectize#139

It allows for an easy way to add a special 'clear option' in the dropdown itself. When selected, it will clear the input.
For the directive, the name of the option is added as an attribute, so for instance it can be
<input type='text' selectize options='[]' clear-option='Any'>

I guess a possibility like this in the selectize library itself would not only solve the problem, but be a nice feature?

skaermbillede 2016-06-09 kl 21 53 57

@joallard joallard changed the title Chome for mobile - backspace doesn't work Backspace not fired when cursor after item in Chrome for Android Jun 9, 2016
@joallard
Copy link
Member

joallard commented Jun 9, 2016

Seeing chromium#118639 was closed as wontfix in Google's infinite wisdom...

@rasmuscnielsen I'm sorry, I'll have to disagree with the UX here. What I could see as viable workarounds however, is that one use the RemoveButton plugin, or have a X on the right side of the field.

@joallard
Copy link
Member

joallard commented Jun 9, 2016

I've fooled around on https://w3c.github.io/uievents/tools/key-event-viewer.html a bit to see what we could do for an ugly workaround.

Here's the event log of what happened:

# 1. Click field, type X

- keydown 229, value ''
- input, 'X'
- keyup 229, 'X'

# 2. Type 'Y'

- keydown 229, 'X'
- input, 'XY'
- keyup 229, 'XY'

# 3. Backspace Y

- input, 'X'
- keydown 229 'X'
- keyup 229 'X'

# 4. Backspace X

- input, ''
- keydown 229 ''
- keyup 229 ''

# 5. Backspace when empty (*)

- keydown 229 ''
- keyup 229 ''

Seems that the one backspace we want is the one that has no input event, and keyup and keydown.

We could work around that, say that if you're on Chrome Android, and the input value was empty, you down 229 and it is still empty, that's a backspace. We could also wait until they release compositionstart and work with that.

agorodezki pushed a commit to agorodezki/selectize.js that referenced this issue Nov 25, 2016
Fix for Android keypress and wrong keycode (selectize#321, selectize#113)
@doydoydoy
Copy link

I'm currently having this issue using Google Keyboard and Huawei Sywpe Keyboard.

@risadams
Copy link
Contributor

risadams commented Dec 1, 2020

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

@risadams risadams closed this as completed Dec 1, 2020
@joshuabach
Copy link

This issue is still occuring on Firefox for Android 106.1.0 (Android 10).

My workaround (insipred by @andreapavon) is

onType: function(text) {
    if (text.length <= 1) {
         this.clear();
    }
}

Which simply clears the control once the user starts typing. Works well enough for me.

joshuabach added a commit to joshuabach/gnucash-web that referenced this issue Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests