feat: allow enter key submission for qa

This commit is contained in:
Jet 2026-03-25 23:57:50 -07:00
parent 6a652ed4f3
commit 1149597139
No known key found for this signature in database

View file

@ -38,6 +38,13 @@ export async function qaPage(outlet: HTMLElement) {
charCount.textContent = `${input.value.length}/200`; charCount.textContent = `${input.value.length}/200`;
}); });
input.addEventListener("keydown", (e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
form.requestSubmit();
}
});
form.addEventListener("submit", (e) => { form.addEventListener("submit", (e) => {
e.preventDefault(); e.preventDefault();
const question = input.value.trim(); const question = input.value.trim();
@ -50,11 +57,13 @@ export async function qaPage(outlet: HTMLElement) {
.then(() => { .then(() => {
input.value = ""; input.value = "";
charCount.textContent = "0/200"; 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)"; status.style.color = "var(--light-green)";
}) })
.catch((err: unknown) => { .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)"; status.style.color = "var(--light-red)";
}); });
}); });