fix: fixed behaviour of bundled app for decrypt and ai chat
This commit is contained in:
@@ -3,6 +3,9 @@ export const ChatSurface = {
|
||||
this.stickToBottom = true;
|
||||
this.scrollContainer = null;
|
||||
|
||||
this._enterKeyHandled = false;
|
||||
this._prevInputValue = "";
|
||||
|
||||
this.autoResize = () => {
|
||||
const textarea = this.el.querySelector(".chat-input");
|
||||
|
||||
@@ -85,11 +88,34 @@ export const ChatSurface = {
|
||||
this.stickToBottom = distanceFromBottom < 48;
|
||||
};
|
||||
|
||||
this._submitChat = () => {
|
||||
const form = this.el.querySelector(".chat-input-wrapper");
|
||||
if (form && typeof form.requestSubmit === "function") {
|
||||
form.requestSubmit();
|
||||
} else {
|
||||
const sendButton = this.el.querySelector("[data-testid='chat-send-button']");
|
||||
if (sendButton) sendButton.click();
|
||||
}
|
||||
};
|
||||
|
||||
this.handleInput = (event) => {
|
||||
if (!event.target.closest(".chat-input")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const textarea = event.target;
|
||||
|
||||
if (!this._enterKeyHandled && textarea.value.includes("\n") && !this._prevInputValue.includes("\n")) {
|
||||
textarea.value = textarea.value.replace(/\n/g, "");
|
||||
this._prevInputValue = textarea.value;
|
||||
this.stickToBottom = true;
|
||||
this.autoResize();
|
||||
this._submitChat();
|
||||
return;
|
||||
}
|
||||
|
||||
this._enterKeyHandled = false;
|
||||
this._prevInputValue = textarea.value;
|
||||
this.stickToBottom = true;
|
||||
this.autoResize();
|
||||
};
|
||||
@@ -101,12 +127,8 @@ export const ChatSurface = {
|
||||
|
||||
if (event.key === "Enter" && !event.shiftKey && !event.isComposing) {
|
||||
event.preventDefault();
|
||||
|
||||
const sendButton = this.el.querySelector("[data-testid='chat-send-button']");
|
||||
|
||||
if (sendButton && !sendButton.disabled) {
|
||||
sendButton.click();
|
||||
}
|
||||
this._enterKeyHandled = true;
|
||||
this._submitChat();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user