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 <vitalii.maznyi@fasterthanlight.me>
pull/813/merge
VitaliyMaznyi 2022-11-09 17:51:17 +01:00 zatwierdzone przez GitHub
rodzic 5eeb98d39d
commit 58b653f1ae
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -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();
}
});