Skip to content

Commit

Permalink
improve input submit (#988)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vitaliy-Maznyi and VitaliyMaznyi committed Nov 9, 2022
1 parent 5eeb98d commit 58b653f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down

0 comments on commit 58b653f

Please sign in to comment.