docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Can't input Japanese on `docusaurus-theme-search-algolia` in Windows Firefox

Open tats-u opened this issue 1 year ago • 18 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [X] I'm using the latest version of Docusaurus.
  • [ ] I have tried the npm run clear or yarn clear command.
  • [ ] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • [ ] I have tried creating a repro with https://new.docusaurus.io.
  • [ ] I have read the console error message carefully (if applicable).

Description

docusaurus-theme-search-algolia has a bug to prevent from inputting Japanese in Windows Firefox. Other languages, e.g. Chinese, may be affected, too. Chromium-based browsers work well.

Reproducible demo

https://docusaurus.io/

Steps to reproduce

  1. Install or enable a Japanese input method (e.g. Google Japanese Input)
  2. Click the search bar or Ctrl + K
  3. Enable Japanese input method
  4. Type some Japanese search query

Expected behavior

https://user-images.githubusercontent.com/12870451/235352380-d6be7c95-c69b-489d-b8eb-d00d5ecdc499.mp4

(Edge)

Chrome also works well.

Note: this movie uses AV1. Safari may not be supported. Edge requires an this Windows video extension.

Actual behavior

https://user-images.githubusercontent.com/12870451/235352442-ccfbda41-a997-463d-8d56-26a10a3fd361.mp4

Input corrupted at every moment😡

Your environment

  • Public source code: officia pagel
  • Public site URL: official page
  • Docusaurus version used: official
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): N/A
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows + Firefox

Self-service

  • [ ] I'd be willing to fix this bug myself.

tats-u avatar Apr 30 '23 12:04 tats-u

https://developer.mozilla.org/docs/Web/API/Event/composed must be used to fix this problem.

This may be due to https://github.com/algolia/autocomplete

tats-u avatar Apr 30 '23 12:04 tats-u

I cannot reproduce this in macOS Firefox, but Chinese input methods work differently and I don't know how to use the Hiragana input method... In any case, Docusaurus does not provide the search modal, so we will track https://github.com/algolia/autocomplete/issues/1135 instead.

Josh-Cena avatar Apr 30 '23 22:04 Josh-Cena

@Josh-Ce I don't have a mac, but can't it be reproduced in Microsoft Pinyin in Windows parallels either? (I'll try it later in physical Windows though)

tats-u avatar Apr 30 '23 23:04 tats-u

Unfortunately I don't have access to a Windows machine either :/

Josh-Cena avatar Apr 30 '23 23:04 Josh-Cena

fyi how to enable Japanese IME in macOS

https://redcocoon.org/cab/mysoft.html

tats-u avatar Apr 30 '23 23:04 tats-u

Yeah I do have the Hiragana keyboard, I just never know how to use it.

Test

Josh-Cena avatar May 01 '23 00:05 Josh-Cena

Seems to work well. It may be Windows specific.

tats-u avatar May 01 '23 09:05 tats-u

I was able to test in Google Pinyin in Windows Sandbox.

https://user-images.githubusercontent.com/12870451/235466914-83505fb2-2bad-4a77-8191-75da32a24f49.mp4

Input a sentence→Press backspace until all characters are deleted While I pressed backspace, I found the search bar behaves suspiciously (as if I pressed a space).

woxihuan→[backspace]→・・・→woxih (OK until here)→[backspace]→我系 (IME closed; I can't modify pinyin anymore)

https://user-images.githubusercontent.com/12870451/235468828-fecdbca5-304c-4646-bd67-8c91c5448e1b.mp4

Another example (I just pressed backspace once after typing huanghe)

Google Pinyin: 下载谷歌拼音输入法 Download Google Pinyin Chinese Mandarin Pinyin Input (Direct link: Download Google Pinyin [ 标准版 ] For Microsoft Windows | GeckoandFly Server)

tats-u avatar May 01 '23 14:05 tats-u

Can macOS + Firefox input Pinyin on the field in this pen successfully?

https://codepen.io/tats-u/pen/KKGXxEM

tats-u avatar May 02 '23 14:05 tats-u

@tats-u sorry I was quite busy for the last few weeks. Yes, the pen works for me on Mac Firefox, both using Chinese and Hiragana keyboards.

The IME closing seems unexpected, but I can't reproduce it here. Maybe it's a platform-specific issue?

Josh-Cena avatar May 22 '23 16:05 Josh-Cena

macOS doesn't seem to be affected. Thank you for your cooperation.

FYI in Windows:

https://user-images.githubusercontent.com/12870451/235846510-b8fc90b6-2ee6-44e0-8a61-1d025bb58ec0.mp4

tats-u avatar May 24 '23 21:05 tats-u

https://github.com/algolia/autocomplete/issues/1135#issuecomment-1916879932

We will be able to fix this issue by ignoreCompositionEvents in the latest autocomplete for CJK languages.

@Josh-Cena Now that the ball is in our court, could you reopen this issue?

tats-u avatar Mar 19 '24 12:03 tats-u

@tats-u Could you try it in your environment? Thanks!

Josh-Cena avatar Mar 24 '24 18:03 Josh-Cena

Has it been committed in main? It does not look like.

tats-u avatar Mar 24 '24 23:03 tats-u

Ah, no, I meant if you wanted to make the code change and test it locally.

Josh-Cena avatar Mar 24 '24 23:03 Josh-Cena

I see. I found that we still have to wait for fix of https://github.com/algolia/docsearch/issues/1043 & https://github.com/algolia/docsearch/issues/1304. That attribute has not been imported into <DocSearchModal/> (@docsearch/react) yet.

We have only to add a line in packages\docusaurus-theme-search-algolia\src\theme\SearchBar\index.tsx.

Should we use useDocusaurusContext().i18n.currentLocale to check if that attribute should be designated?

tats-u avatar Mar 25 '24 10:03 tats-u

Is there a downside to this being unconditionally applied?

Josh-Cena avatar Mar 25 '24 13:03 Josh-Cena

You may want to see:

https://github.com/algolia/instantsearch/issues/5986 https://github.com/algolia/instantsearch/pull/6009

It is up to your team to apply this to all locales. I am against their background, though. The detailed condition (the name of Ithe keyboard app & the language of the keyboard) is not written. I think Gboard (English & Japanese) for Pixel works well.

tats-u avatar Mar 25 '24 14:03 tats-u