feat: allow enter key submission for qa
This commit is contained in:
parent
6a652ed4f3
commit
1149597139
1 changed files with 11 additions and 2 deletions
|
|
@ -38,6 +38,13 @@ export async function qaPage(outlet: HTMLElement) {
|
|||
charCount.textContent = `${input.value.length}/200`;
|
||||
});
|
||||
|
||||
input.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter" && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
form.requestSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
form.addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const question = input.value.trim();
|
||||
|
|
@ -50,11 +57,13 @@ export async function qaPage(outlet: HTMLElement) {
|
|||
.then(() => {
|
||||
input.value = "";
|
||||
charCount.textContent = "0/200";
|
||||
status.textContent = "Question submitted! It will appear here once answered.";
|
||||
status.textContent =
|
||||
"Question submitted! It will appear here once answered.";
|
||||
status.style.color = "var(--light-green)";
|
||||
})
|
||||
.catch((err: unknown) => {
|
||||
status.textContent = err instanceof Error ? err.message : "Failed to submit question.";
|
||||
status.textContent =
|
||||
err instanceof Error ? err.message : "Failed to submit question.";
|
||||
status.style.color = "var(--light-red)";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue