Skip to content

Commit b7018d5

Browse files
Merge pull request #196 from OpenAssistantGPT/feat/before-chat
feat: add feature to disable chat inputs
2 parents 6279fa8 + 116076b commit b7018d5

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.changeset/cool-stingrays-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@openassistantgpt/ui': patch
3+
---
4+
5+
Add new feature to disable chat inputs

examples/website-chatbot-window/app/window/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default function ChatPage() {
5252
extensions={[<SupportInquiry key="first" />]}
5353
handleAfterChat={() => console.log('after chat')}
5454
handleBeforeChat={() => console.log('before chat')}
55+
disableInput={true}
5556
annotationsFiles={[
5657
{
5758
fileName: 'google',

packages/ui/components/chat.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ interface ChatbotProps {
4242
onThreadIdChange?: (threadId: string | undefined) => void;
4343
handleBeforeChat?: () => Promise<void> | void;
4444
handleAfterChat?: () => Promise<void> | void;
45+
disableInput?: boolean; // New option to disable the input
4546
}
4647

4748
export function OpenAssistantGPTChat({
@@ -57,6 +58,7 @@ export function OpenAssistantGPTChat({
5758
handleBeforeChat,
5859
handleAfterChat,
5960
extensions,
61+
disableInput = false, // Default value for the new option
6062
...props
6163
}: ChatbotProps) {
6264
let inputFileRef = useRef<HTMLInputElement>(null);
@@ -425,6 +427,7 @@ export function OpenAssistantGPTChat({
425427
multiple
426428
onChange={handleFileChange}
427429
tabIndex={-1}
430+
disabled={disableInput}
428431
/>
429432
</div>
430433
)}
@@ -449,6 +452,7 @@ export function OpenAssistantGPTChat({
449452
rows={1}
450453
value={input}
451454
onChange={handleInputChange}
455+
disabled={disableInput}
452456
/>
453457
</div>
454458
<div className={`absolute top-[14px] right-0`}>
@@ -457,7 +461,7 @@ export function OpenAssistantGPTChat({
457461
{status === 'awaiting_message' ? (
458462
<Button
459463
id="submit"
460-
disabled={input === ''}
464+
disabled={input === '' || disableInput} // Disable the send button when disableInput is true
461465
type="submit"
462466
size="icon"
463467
>

0 commit comments

Comments
 (0)