Skip to content

Commit

Permalink
fix: Fix an issue where users cannot enter new line in chat input
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed May 20, 2024
1 parent a3f1559 commit 55da3bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/ChatBotBody/ChatBotBody.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
font-size: 15px;
overflow-wrap: anywhere;
overflow: hidden;
white-space: pre-wrap;
}

.rcb-bot-message {
Expand Down
7 changes: 6 additions & 1 deletion src/components/ChatBotInput/ChatBotInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ const ChatBotInput = ({
*/
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement | HTMLInputElement>) => {
if (event.key === "Enter") {
event.preventDefault();
if (event.shiftKey) {
if (!botOptions.chatInput?.allowNewline) {
event.preventDefault();
}
return;
}
handleSubmit(event);
}
};
Expand Down
1 change: 1 addition & 0 deletions src/services/BotOptionsService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const defaultOptions = {
},
chatInput: {
disabled: false,
allowNewline: false,
enabledPlaceholderText: "Type your message...",
disabledPlaceholderText: "",
showCharacterCount: false,
Expand Down

0 comments on commit 55da3bf

Please sign in to comment.