From 58b653f1ae8fa533c8fed8dd97c5f5add797327c Mon Sep 17 00:00:00 2001 From: VitaliyMaznyi Date: Wed, 9 Nov 2022 17:51:17 +0100 Subject: [PATCH] improve input submit (#988) add check to input component if japanese character is chosen by pressing enter key and prevent form submitting Co-authored-by: VitaliyMaznyi --- src/components/input/input.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/input/input.ts b/src/components/input/input.ts index 6ad18041..ce5dcbd3 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -319,7 +319,9 @@ export default class SlInput extends ShoelaceElement { // submitting to allow users to cancel the keydown event if they need to if (event.key === 'Enter' && !hasModifier) { setTimeout(() => { - if (!event.defaultPrevented) { + // isComposing is true when enter key is pressed while choosing the chinese/japanese/etc character + // so this check will prevent form submitting after choosing character by enter key pressing + if (!event.defaultPrevented && !event.isComposing) { this.formSubmitController.submit(); } });