autocomplete
autocomplete copied to clipboard
fix(composition): do not submit when user is composing
"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 romaji characters.
Fixes https://github.com/algolia/docsearch/issues/1304 Fixes https://github.com/algolia/docsearch/issues/1043
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit ffe77712a4efddf80bcd380c9d183576927c4f73:
Sandbox | Source |
---|---|
@algolia/autocomplete-example-github-repositories-custom-plugin | Configuration |
@algolia/autocomplete-example-instantsearch | Configuration |
@algolia/autocomplete-example-playground | Configuration |
@algolia/autocomplete-example-preview-panel-in-modal | Configuration |
@algolia/autocomplete-example-react-renderer | Configuration |
@algolia/autocomplete-example-starter-algolia | Configuration |
@algolia/autocomplete-example-starter | Configuration |
@algolia/autocomplete-example-reshape | Configuration |
Thanks @Haroenv for opening this ticket, let's try to move it forward.
From what I understand of this isComposing
API, it triggers in any situation where a user is considered in a "composition session" (e.g., in Pinyin IME as on the linked DocSearch issue, when typing a letter modifier such as "`" or "~").
Should we consider not triggering any input event (no searches, no navigations, etc.) when a user is still composing? Looking at https://github.com/algolia/docsearch/issues/1304, it seems confusing for users to have both autocompletes update at the same time, and that both seem to have focus and receive commands.
It'd feel cleaner not to trigger anything when the user is in a composition session, and only do so when they exit it.
Happy to hear opinions, cc @francoischalifour @Haroenv @dhayab.
@sarahdayan I'm not familiar with accessibility regarding composing. This is the kind of feature that we shouldn't guess by ourselves, but rather follow accessibility recommendations for combobox/autocomplete experiences.
This fix is integrated and tested in https://github.com/algolia/autocomplete/pull/1226.