revolist / revogrid

Powerful virtual data grid smartsheet with advanced customization. Best features from excel plus incredible performance 🔋
https://rv-grid.com
MIT License
2.68k stars 166 forks source link

All cell changes are ignored on Android/Chrome #368

Open atsepkov opened 1 year ago

atsepkov commented 1 year ago

Describe the issue There is no way to enter a value into the cell/grid on Android device because the enter key gets ignored while inside the cell (reproduced on 3 Android devices w/ Chrome browser (including a tablet), on iPhone and PC the enter key works fine).

To Reproduce

This initially led me to believe that perhaps Android keyboard's enter/go key actually sends a different keyCode than regular enter key (13), but opening a keycode tester on my Android device seemed to confirm that "go" key on the keyboard sstill sends the keyCode of 13 (like standard enter key).

In addition to the enter key not working, I would actually prefer the default behavior be the same as with Excel (losing focus = enter rather than cancel), if it's possible to implement or even achieve myself via events as it would partially mitigate the above bug - this behavior seems more intuitive, especially on mobile devices.

atsepkov commented 1 year ago

Glancing through RevoGrid codebase, I'm wondering if https://github.com/revolist/revogrid/blob/99b8e4af2aa2b53283801fcd3425ff2f636f50e7/src/components/overlay/editors/text.tsx#L27 is the culprit. Since the keyCode does match, maybe one of the other properties this conditional expects isn't being set on Android?

ellis2323 commented 11 months ago

It doesn t work with android devices. I have tested with my pixel pro 6 and a samsung tab s7

ellis2323 commented 11 months ago

I have debug with my devices. It seems code is "" and you don't use the keycode. If you change src/utils/keyCodes.utils.ts to check if e.key === 'Enter', it fixes the problem. Probably better to e.key.toLowerCase() === 'enter'.

https://snipboard.io/CPZrWD.jpg

atsepkov commented 11 months ago

Good catch, my suggestion would be to update the 2 locations (https://github.com/search?q=repo%3Arevolist%2Frevogrid%20isEnterKey&type=code) to use e.keyCode or e.key. IMO keyCodes should be consistent on all platforms, even international keyboards, whereas I'm not 100% sure the same holds for the string name.

atsepkov commented 11 months ago

@ellis2323 based on how old this issue is, I doubt it will be looked at unless one of us pushes a PR. Do you want to do it or should I?

ellis2323 commented 11 months ago

I have holiday until monday. I can create a PR monday. And not sure what’s the best solution to check if it’s a enter. The author lib might have a preference.

ellis2323 commented 11 months ago

As stated in the doc, keyCode is deprecated. We should use the key field to check if it is a enter. The code field with a virtual keyboard try to find the equivalent key but in our case it return ’’ Html doc

A tester: https://dvcs.w3.org/hg/d4e/raw-file/tip/key-event-test.html

ellis2323 commented 11 months ago

There is an attribute html which could fix the pb. If we add enterkeyhint="enter", i think the key will be correct. After a try, it doesn't change the code value.

ellis2323 commented 11 months ago

I have created a pull request: https://github.com/revolist/revogrid/pull/422