Skip to content

Commit

Permalink
keyboard Enter submit (#4991)
Browse files Browse the repository at this point in the history
Co-authored-by: Dong Lei <donglei@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
  • Loading branch information
3 people authored Nov 30, 2020
1 parent e4c6c71 commit ea34b18
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Composer/packages/client/src/components/EditableField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ const EditableField: React.FC<EditableFieldProps> = (props) => {
fieldRef.current?.blur();
};

// single line, press Enter to submit
// multipe line, press Enter to submit, Shift+Enter get a new line,
const handleOnKeyDown = (e) => {
if (e.key === 'Enter' && expanded) {
const enterOnField = e.key === 'Enter' && hasFocus;
const multilineEnter = multiline ? !e.shiftKey : true;
if (enterOnField && multilineEnter) {
handleCommit();
}
if (e.key === 'Escape') {
Expand Down

0 comments on commit ea34b18

Please sign in to comment.