quip / quip-apps

Quip Live Apps API for creating applications in Quip documents.
Apache License 2.0
107 stars 75 forks source link

On Android returning `true` from the `handleKeyEvent` of a `RichTextBox` does not prevent the event #69

Open dharmateja369 opened 4 years ago

dharmateja369 commented 4 years ago

We are Using the handlekeyevent function in richtextbox for the character count this was working fine in ios and browser and desktop quip app. But it was not working on the android so somebody can please help with the issue.

@gabesoft

gabesoft commented 4 years ago

@dharmateja369 how would we reproduce the issue? Also, is it broken on all Android versions or a particular one? In addition, does it not work when the user types on the keyboard, or when they swipe, or autocorrect? In some of those cases there will be no keyboard event fired, instead input events will be fired.

dharmateja369 commented 4 years ago

@gabesoft the keyboard event is firing but the problem that I saw when it reached the character limit we are not able to stop the user to type further character limit. So the code was working fine in all other browsers, ios, quip apps for desktop. So to debug can your team can help us on android. You can reproduce this bug was on the v2mom app and the version it was not working on Version 7.8.1 - 708010

gabesoft commented 4 years ago

Spend some time debugging this issue with @dharmateja369. Looks like the problem is that on Android calling preventDefault on a keyboard event does not actually cancel the event. The event does get fired but it can't be prevented.

jesseditson commented 4 years ago

Sorry, finding time to get caught up now. Am I correct in assuming that this is an Android bug rather than a Quip one or did I misread the above comment?

gabesoft commented 4 years ago

Yes, it's an Android bug. On Android calling preventDefault inside a keydown event with keyCode 229 does not prevent the key from being entered. More info about this issue in this blog post https://clark.engineering/input-on-android-229-unidentified-1d92105b9a04 and https://stackoverflow.com/questions/59212595/event-preventdefault-doesnt-work-with-keycode-229

gabesoft commented 4 years ago

But this does looks like a Quip bug on Android because in our docs we're saying that returning true from handleKeyEvent prevents the event from being processed.

handleKeyEvent: PropTypes.func
Callback for keyboard events when this RichTextBox is focused. If handleKeyEvent returns true, the event is not passed to the RichTextBox to be processed
gabesoft commented 4 years ago

CC @ostacey in case you’re aware of a fix

jesseditson commented 4 years ago

This is a pretty in the weeds fix for a small affected audience but the feature detection seems doable based on that blog post. We have a number of accessibility fixes that I’m tempted to group this with, but timeline on those is unclear so far.