Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion js/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ class ChatInput extends LightElement {
this.#onInput();
}

// Recheck button state when `this.disabled` updates
updated(changedProperties: Map<string, unknown>) {
if (changedProperties.has("disabled")) {
this.#onInput();
}
}

#sendInput(): void {
if (this.valueIsEmpty) return;
if (this.disabled) return;
Expand All @@ -282,11 +289,11 @@ class ChatInput extends LightElement {
this.setInputValue("");

this.textarea.focus();
this.disabled = true; // Will be re-enabled by #finalizeMessage() when we get a response
}

setInputValue(value: string): void {
this.textarea.value = value;
this.disabled = value.trim().length === 0;

// Simulate an input event (to trigger the textarea autoresize)
const inputEvent = new Event("input", { bubbles: true, cancelable: true });
Expand Down Expand Up @@ -451,6 +458,7 @@ class ChatContainer extends LightElement {
}

#finalizeMessage(): void {
console.log("message finalized!");
this.input.disabled = false;
}

Expand Down
2 changes: 1 addition & 1 deletion shiny/www/py-shiny/chat/chat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions shiny/www/py-shiny/chat/chat.js.map

Large diffs are not rendered by default.

Loading