Skip to content

[minor] New Message Input component implementation#2504

Open
PelayoFelgueroso wants to merge 20 commits into
masterfrom
PelayoFelgueroso/message-input
Open

[minor] New Message Input component implementation#2504
PelayoFelgueroso wants to merge 20 commits into
masterfrom
PelayoFelgueroso/message-input

Conversation

@PelayoFelgueroso

Copy link
Copy Markdown
Collaborator

Checklist
(Check off all the items before submitting)

  • Build process is done without errors. All tests pass in the /lib directory.
  • Self-reviewed the code before submitting.
  • Meets accessibility standards.
  • Added/updated documentation to /website as needed.
  • Added/updated tests as needed.

Purpose
Implemente the new message input component based on the design.

const [isFocused, setIsFocused] = useState(false);
const fileInputRef = useRef<HTMLInputElement | null>(null);
const { transcript, isRecording, startRecording, stopRecording, resetTranscript } = useVoiceTranscription({
lang: locale ?? "en-US",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change it so that the default value of locale is "en-US" instead of defaulting to en-US if locale is undefined.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


const handleInputOnChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
const el = event.target;
el.style.height = "auto";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to change the scrollHeight to achieve a growing textarea.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
`;

const Input = styled.textarea<{ isRecording?: boolean }>`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable should be more descriptive. Input is just too generic.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

`;

const InputWrapper = styled.div`
max-height: 150px;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this max-height comes from? Based on the design the max height is for the whole component, so the maximun height can change depending how many elements are inside the message input.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

const InputWrapper = styled.div`
max-height: 150px;
position: relative;
flex-grow: 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the point of this flex grow and direction.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

medium: "360px",
large: "480px",
fillParent: "100%",
fillParent: "fit-content",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fill parent should always be 100% size.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review all the visual test cases, there are multiple that does not make sense as visual tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

fileInput.dispatchEvent(new Event("change", { bubbles: true }));

expect(callbackFile).toHaveBeenCalled();
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a transcript test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

* The type parameter indicates whether it's a "submit" or "stop" event.
* For submit events, an AbortSignal is provided to allow cancellation.
*/
onButtonClick?: (type: "submit" | "stop") => void;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we considered about passing all the relevant information on submit to the user in case the component is not controlled? That makes proccessing the input far easier.

};

recognition.onerror = (event: SpeechRecognitionErrorEvent) => {
console.error("Speech recognition error:", event.error);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error should be sent to the message input to display any possible error related to the voice transcript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants