Skip to content

Commit

Permalink
fix(composition): do not submit when user is composing
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
Haroenv authored Feb 21, 2022
1 parent 4430816 commit 685547f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/autocomplete-core/src/onKeyDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function onKeyDown<TItem extends BaseItem>({
// pending and could reopen the panel once they resolve, because that would
// result in an unsolicited UI behavior.
store.pendingRequests.cancelAll();
} else if (event.key === 'Enter') {
} else if (event.key === 'Enter' && !event.isComposing) {
// No active item, so we let the browser handle the native `onSubmit` form
// event.
if (
Expand Down

0 comments on commit 685547f

Please sign in to comment.