diff --git a/scm-ui/ui-components/src/forms/Textarea.stories.tsx b/scm-ui/ui-components/src/forms/Textarea.stories.tsx
new file mode 100644
index 0000000000..a27b2b738c
--- /dev/null
+++ b/scm-ui/ui-components/src/forms/Textarea.stories.tsx
@@ -0,0 +1,56 @@
+import React, {useState} from "react";
+import { storiesOf } from "@storybook/react";
+import styled from "styled-components";
+import Textarea from "./Textarea";
+
+const Spacing = styled.div`
+ padding: 2em;
+`;
+
+const OnChangeTextarea = () => {
+ const [value, setValue] = useState("Start typing");
+ return (
+
+
+ );
+};
+
+const OnSubmitTextare = () => {
+ const [value, setValue] = useState("Use the ctrl/command + Enter to submit the textarea");
+ const [submitted, setSubmitted] = useState("");
+
+ const submit = () => {
+ setSubmitted(value);
+ setValue("");
+ };
+
+ return (
+
+
+ );
+};
+
+const OnCancelTextare = () => {
+ const [value, setValue] = useState("Use the escape key to clear the textarea");
+
+ const cancel = () => {
+ setValue("");
+ };
+
+ return (
+
+
+ );
+};
+
+storiesOf("Forms|Textarea", module)
+ .add("OnChange", () => )
+ .add("OnSubmit", () => )
+ .add("OnCancel", () => );
diff --git a/scm-ui/ui-components/src/forms/Textarea.tsx b/scm-ui/ui-components/src/forms/Textarea.tsx
index 694fcf50f0..90ae07b576 100644
--- a/scm-ui/ui-components/src/forms/Textarea.tsx
+++ b/scm-ui/ui-components/src/forms/Textarea.tsx
@@ -27,17 +27,16 @@ class Textarea extends React.Component {
this.props.onChange(event.target.value, this.props.name);
};
- onKeyPress = (event: KeyboardEvent) => {
- const { onSubmit } = this.props;
- if (onSubmit && event.key === "Enter" && event.ctrlKey) {
- onSubmit();
- }
- };
-
onKeyDown = (event: KeyboardEvent) => {
const { onCancel } = this.props;
if (onCancel && event.key === "Escape") {
onCancel();
+ return;
+ }
+
+ const { onSubmit } = this.props;
+ if (onSubmit && event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
+ onSubmit();
}
};
@@ -57,7 +56,6 @@ class Textarea extends React.Component {
onChange={this.handleInput}
value={value}
disabled={!!disabled}
- onKeyPress={this.onKeyPress}
onKeyDown={this.onKeyDown}
/>