algolia / docsearch

:blue_book: The easiest way to add search to your documentation.
https://docsearch.algolia.com
MIT License
3.97k stars 384 forks source link

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

Open hisaichi5518 opened 2 years ago

hisaichi5518 commented 2 years ago

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

axilleas commented 2 years ago

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

shortcuts commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

shortcuts commented 2 years ago

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

dhayab commented 8 months ago

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