Skip to content

Commit

Permalink
fix: Fix issue with chatbot losing focus after input
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed Jul 25, 2024
1 parent 1d17e65 commit dc8ea78
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/ChatBotContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ const ChatBotContainer = ({ flow }: { flow: Flow }) => {

// cleanup logic after preprocessing of a block
setIsBotTyping(false);
if (!block.chatDisabled) {
if (!("chatDisabled" in block)) {
setTextAreaDisabled(settings.chatInput?.disabled as boolean);
}
setBlockAllowsAttachment(typeof block.file === "function");
Expand Down Expand Up @@ -551,7 +551,7 @@ const ChatBotContainer = ({ flow }: { flow: Flow }) => {
* Updates text area focus based on current block's text area.
*/
const updateTextAreaFocus = useCallback((currPath: string) => {
if (!textAreaDisabled) {
if (!inputRef.current?.disabled) {
setTimeout(() => {
if (settings.general?.embedded) {
// for embedded chatbot, only do input focus if chatbot is still visible on page
Expand All @@ -566,19 +566,19 @@ const ChatBotContainer = ({ flow }: { flow: Flow }) => {
}
}, 100)
}
}, [textAreaDisabled]);
}, []);

/**
* Handles toggling of voice.
*
* @param event mouse event
*/
const handleToggleVoice = useCallback(() => {
if (textAreaDisabled) {
if (inputRef.current?.disabled) {
return;
}
setVoiceToggledOn(prev => !prev);
}, [textAreaDisabled]);
}, []);

/**
* Handles sending of user input to check if should send as plain text or sensitive info.
Expand Down Expand Up @@ -680,7 +680,7 @@ const ChatBotContainer = ({ flow }: { flow: Flow }) => {
}
}, settings.chatInput?.botDelay);
}, [timeoutId, voiceToggledOn, settings, flow, getPrevPath, injectMessage, streamMessage, openChat,
postProcessBlock, setPaths, updateTextAreaFocus, handleSendUserInput
postProcessBlock, setPaths, handleSendUserInput
]);

/**
Expand Down

0 comments on commit dc8ea78

Please sign in to comment.