docsearch icon indicating copy to clipboard operation
docsearch copied to clipboard

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

Open hisaichi5518 opened this issue 3 years ago • 6 comments

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:

  • https://jestjs.io/ja/

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

hisaichi5518 avatar Feb 15 '22 15:02 hisaichi5518

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

axilleas avatar Feb 17 '22 12:02 axilleas

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 🤔

shortcuts avatar Feb 17 '22 12:02 shortcuts

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

hisaichi5518 avatar Feb 20 '22 13:02 hisaichi5518

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

Haroenv avatar Feb 21 '22 08:02 Haroenv

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

shortcuts avatar Feb 21 '22 09:02 shortcuts

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

dhayab avatar Jan 30 '24 17:01 dhayab