Skip to content

Commit

Permalink
29 can send multiple messages 2 (#406)
Browse files Browse the repository at this point in the history
* disables send button when message is sending

* prevents pressing enter to send msessage while message is sending

* puts classname back onto wrapper div

* run formatter

* stops send button having different styling when loading

* runs formatter
  • Loading branch information
pmarsh-scottlogic authored Oct 18, 2023
1 parent 93aae49 commit e9dca4f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/ChatBox/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function ChatBox({

function inputKeyUp(event: KeyboardEvent<HTMLTextAreaElement>) {
// shift+enter shouldn't send message
if (event.key === "Enter" && !event.shiftKey) {
if (event.key === "Enter" && !event.shiftKey && !isSendingMessage) {
// asynchronously send the message
void sendChatMessage();
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/ThemedButtons/LoadingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function LoadingButton({
isLoading?: boolean;
}) {
return (
<ThemedButton {...buttonProps}>
<ThemedButton
isDisabled={isLoading}
appearsDifferentWhenDisabled={false}
{...buttonProps}
>
{isLoading ? (
<span className="loader">
<ThreeDots width="24px" color="white" />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/ThemedButtons/ThemedButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
color: var(--main-button-active-hover-text-colour);
}

.themed-button[disabled] {
.themed-button.appearsDifferentWhenDisabled[disabled] {
background-color: var(--main-button-disabled-background-colour);
color: var(--main-button-disabled-text-colour);
cursor: default;
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/ThemedButtons/ThemedButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ export interface ThemedButtonProps {
isDisabled?: boolean;
isSelected?: boolean;
onClick: () => void;
appearsDifferentWhenDisabled?: boolean;
}

function ThemedButton({
children,
onClick,
isDisabled = false,
isSelected = false,
appearsDifferentWhenDisabled = true,
}: ThemedButtonProps) {
const buttonClass = clsx("themed-button", { selected: isSelected });
const buttonClass = clsx("themed-button", {
selected: isSelected,
appearsDifferentWhenDisabled: appearsDifferentWhenDisabled,
});

return (
<button className={buttonClass} onClick={onClick} disabled={isDisabled}>
Expand Down

0 comments on commit e9dca4f

Please sign in to comment.