Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Saisakul Chernbumroong authored and Saisakul Chernbumroong committed Feb 28, 2025
2 parents c7d6d98 + 5b79a0d commit 6546347
Show file tree
Hide file tree
Showing 12 changed files with 634 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ REDBOX_API_KEY = myapi
# AUTHBROKER_CLIENT_SECRET=REPLACE_WITH_GITLAB_SECRET
# AUTHBROKER_URL=https://sso.trade.gov.uk

ENABLE_METADATA_EXTRACTION = True
ENABLE_METADATA_EXTRACTION = True
SELF_ROUTE_ENABLED = False
8 changes: 8 additions & 0 deletions django_app/frontend/src/chat-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,14 @@ main:has(.iai-chat-bubble) .chat-options {
}
}

.iai-chat-input__input {
background-color: white;
border: #767676 1px solid;
min-height: 1.5em;
max-height: 200px;
overflow-y: auto;
}

.exit-feedback {
background-color: #f3edc9;
display: none;
Expand Down
10 changes: 5 additions & 5 deletions django_app/frontend/src/js/web-components/chats/message-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export class MessageInput extends HTMLElement {
constructor() {
super();
this.textarea = this.querySelector("textarea");
this.textarea = this.querySelector(".iai-chat-input__input");
}

connectedCallback() {
Expand All @@ -15,7 +15,7 @@ export class MessageInput extends HTMLElement {
this.textarea.addEventListener("keypress", (evt) => {
if (evt.key === "Enter" && !evt.shiftKey && this.textarea) {
evt.preventDefault();
if (this.textarea.value.trim()) {
if (this.textarea?.textContent?.trim()) {
this.closest("form")?.requestSubmit();
}
}
Expand All @@ -32,15 +32,15 @@ export class MessageInput extends HTMLElement {
return;
}
this.textarea.style.height = "auto";
this.textarea.style.height = `${this.textarea.scrollHeight}px`;
this.textarea.style.height = `${this.textarea.scrollHeight || this.textarea.offsetHeight}px`;
};

/**
* Returns the current message
* @returns string
*/
getValue = () => {
return this.querySelector("textarea")?.value.trim() || "";
return this.textarea?.textContent?.trim() || "";
};

/**
Expand All @@ -50,7 +50,7 @@ export class MessageInput extends HTMLElement {
if (!this.textarea) {
return;
}
this.textarea.value = "";
this.textarea.textContent = "";
this.#adjustHeight();
};
}
Expand Down
2 changes: 1 addition & 1 deletion django_app/redbox_app/templates/chats.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h2 class="chat-title__heading govuk-visually-hidden" hidden>Current chat</h2>
Message Redbox
</label>
<message-input>
<textarea class="iai-chat-input__input js-user-text" id="message" name="message" rows="1" required autofocus></textarea>
<div class="iai-chat-input__input js-user-text" id="message" name="message" contenteditable="true" role="textbox" aria-multiline="true"></div>
</message-input>
</div>
<send-message>
Expand Down
Loading

0 comments on commit 6546347

Please sign in to comment.