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

When typing Japanese, pressing the Enter key to confirm completion selects the document. #1304

Open
hisaichi5518 opened this issue Feb 15, 2022 · 6 comments · Fixed by algolia/autocomplete#1226 or algolia/autocomplete#1238

Comments

@hisaichi5518
Copy link

hisaichi5518 commented Feb 15, 2022

Description

Pressing Enter when the text input is not finalized will take you to the document.

Steps to reproduce

  1. Type Japanese using Google Japanese Input.
  2. Press the Enter key to confirm your input.
  3. redirect to the document.

Live reproduction:

Untitled

Expected behavior

  1. Input Japanese using Google Japanese Input.
  2. Press the Enter key to confirm your input.
  3. The input is confirmed.

Environment

  • OS: macOS 11.6.2
  • Browser: Google Chrome
  • DocSearch version: 3.0.0
@axilleas
Copy link

AFAIK, this is the default behavior, not sure if there's a way to change that.

@shortcuts
Copy link
Member

Hey,

AFAIK, this is the default behavior, not sure if there's a way to change that.

Indeed here two of the input sources are focused, so pressing enter will submit both form.

Using the mouse to select the Japanese text shouldn't trigger the search (which is expected), but I don't think there's a fix to that 🤔

@hisaichi5518
Copy link
Author

hisaichi5518 commented Feb 20, 2022

Thank you for your reply.

Using the mouse to select the Japanese text shouldn't trigger the search (which is expected), but I don't think there's a fix to that 🤔

Yes, if I select the Japanese text with the mouse the search will not be executed.

We can use KeyboardEvent.isComposing to change it so that pressing enter will not search when the input is not finalized.

The KeyboardEvent.isComposing returns true when the input is not finalized.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing

@Haroenv
Copy link
Contributor

Haroenv commented Feb 21, 2022

I think we could check isComposing here: https://github.com/algolia/autocomplete/blob/next/packages/autocomplete-core/src/onKeyDown.ts#L108

Haroenv added a commit to algolia/autocomplete that referenced this issue Feb 21, 2022
"composing" is used on Japanese (and other CJK scripts) when typing on a qwerty or similar keyboard, showing something akin to autocomplete on iOS. You confirm a word by pressing enter, which shouldn't commit to a search.

Still needs to be tested thoroughly, as it's possible we need to check isComposing earlier to prevent searching for the intermediate romanji characters.

Fixes algolia/docsearch#1304
Fixes algolia/docsearch#1043
@shortcuts
Copy link
Member

I did not know about this option! It indeed looks like it should be fixed at the AC level, good catch

@dhayab
Copy link
Member

dhayab commented Jan 30, 2024

Reopening this issue to let the docsearch team handle updating autocomplete and forwarding ignoreCompositionEvents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment