Skip to content

Commit

Permalink
fix: prevent double submissions in korean (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi authored Aug 22, 2022
1 parent 8c720f4 commit 5d781d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/AutoCompleteTextarea/Textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ export class ReactTextareaAutocomplete extends React.Component {
return this.textareaRef.selectionEnd;
};

_defaultShouldSubmit = (event) => event.key === 'Enter' && !event.shiftKey;
/**
* isComposing prevents double submissions in Korean and other languages.
* starting point for a read:
* https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing
* In the long term, the fix should happen by handling keypress, but changing this has unknown implications.
* @param event React.KeyboardEvent
*/
_defaultShouldSubmit = (event) =>
event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing;

_handleKeyDown = (event) => {
const { shouldSubmit = this._defaultShouldSubmit } = this.props;
Expand Down

0 comments on commit 5d781d8

Please sign in to comment.