Skip to content
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

Detect keycode for keyDown in Safari's IME #4186

Merged
merged 1 commit into from
May 23, 2024
Merged

Detect keycode for keyDown in Safari's IME #4186

merged 1 commit into from
May 23, 2024

Conversation

haileyok
Copy link
Contributor

Why

Fixes #4178

Chrome, Firefox, etc. handle the IME very well. If the IME is visible and the key is the enter key, it just dismisses the IME and inserts whatever selection into the input. Naturally though, Safari must not have the same behavior, otherwise our jobs would be too simple.

Specifically, on other browsers, onCompositionEnd is fired after the onKeyDown event is fired. This means that our isComposing value is still true when we decide whether to submit the message or not. However, on Safari, onCompositionEnd is fired before!

Screenshot 2024-05-22 at 8 47 11 PM

Therefore, on Safari, we can check if the Enter press has a keycode of 229. If it does, we do not submit the message.

I also moved the isSafari and isFirefox checks into a separate file browsers.ts and made a browsers.native.ts version that just returns false. We are using these a little more and they are getting duplicated, so might as well add them to one place. I didn't want to use the existing constants.ts since we won't have a .web version of that file.

Test Plan

Same as other browser for IME. Enable the IME, and type some text. Press the enter key to see if it submits or does not. With this PR, Safari should not submit on enter press while the IME is still open.

Screen.Recording.2024-05-22.at.8.52.18.PM.mov

Copy link

render bot commented May 23, 2024

remove debug logs

use a better hack

implement a safari hack

extract `isSafari` and `isFirefox` to a global variable
@haileyok haileyok force-pushed the hailey/safari-ime branch from 3499770 to 2c70d1c Compare May 23, 2024 03:53
Copy link

Old size New size Diff
7.29 MB 7.29 MB -14 B (-0.00%)

@gaearon gaearon merged commit d051614 into main May 23, 2024
6 checks passed
@gaearon gaearon deleted the hailey/safari-ime branch May 23, 2024 15:45
estrattonbailey added a commit that referenced this pull request May 23, 2024
* origin/main:
  Remove `getProfile` calls when loading feed (#3881)
  Log error statuses from failed resume session calls (#4174)
  disable alt text auto focus on Android (#4198)
  [🐴] add link to chat settings from main settings (#4197)
  ✍️ Add OTA Docs (#4187)
  Decrease thickness of border on message input (#4196)
  [🐴] better error message for "Bad token scope" error (#4194)
  Add padding to dialogs when keyboard is open on Android (#4182)
  [🐴] Do not init event bus if no session (#4193)
  stop line breaks for timeelapsed (#4191)
  Reduce polling when app is backgrounded (#4192)
  implement a safari hack for ime (#4186)
  [🐴] Suspend event bus when switching accounts (#4190)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When writing a message in the web DM view, pressing enter for IME conversion causes it to be sent.
3 participants