Skip to content

Commit

Permalink
feat(message-input): prop to messageinput that prevents send on return
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentRoest authored May 31, 2021
1 parent 2c25f50 commit 98fc849
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/MessageInput/MessageInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function MessageInputInner(
activateAfterChange,
disabled,
sendDisabled,
sendOnReturnDisabled,
attachDisabled,
sendButton,
attachButton,
Expand Down Expand Up @@ -148,7 +149,7 @@ function MessageInputInner(
};

const handleKeyPress = (evt) => {
if (evt.key === "Enter" && evt.shiftKey === false) {
if (evt.key === "Enter" && evt.shiftKey === false && sendOnReturnDisabled === false) {
evt.preventDefault();
send();
}
Expand Down Expand Up @@ -233,6 +234,9 @@ MessageInput.propTypes = {
/** A input can show it is currently unable to be interacted with. */
disabled: PropTypes.bool,

/** Prevent that the input message is sent on a return press */
sendOnReturnDisabled: PropTypes.bool,

/** Send button can be disabled.<br>
* It's state is tracked by component, but it can be forced */
sendDisabled: PropTypes.bool,
Expand Down Expand Up @@ -294,6 +298,7 @@ MessageInput.defaultProps = {
value: undefined,
placeholder: "",
disabled: false,
sendOnReturnDisabled: false,
fancyScroll: true,
activateAfterChange: false,
autoFocus: false,
Expand Down

0 comments on commit 98fc849

Please sign in to comment.