Skip to content

Commit 1440d4d

Browse files
committed
fix: Correctly detect auto-submit with bare data-suggestion-submit attribute
1 parent 8f78b5b commit 1440d4d

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

js/chat/chat.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,22 @@ class ChatContainer extends LightElement {
429429
} {
430430
if (!(x instanceof HTMLElement)) return {};
431431

432+
const el = x.closest(".suggestion, [data-suggestion]");
433+
if (!(el instanceof HTMLElement)) return {};
434+
432435
const isSuggestion =
433-
x.classList.contains("suggestion") || x.dataset.suggestion !== undefined;
436+
el.classList.contains("suggestion") ||
437+
el.dataset.suggestion !== undefined;
434438
if (!isSuggestion) return {};
435439

436-
const suggestion = x.dataset.suggestion || x.textContent;
440+
const suggestion = el.dataset.suggestion || el.textContent;
437441

438442
return {
439443
suggestion: suggestion || undefined,
440444
submit:
441-
x.classList.contains("submit") ||
442-
["", "true"].includes(x.dataset.suggestionSubmit || "false"),
445+
el.classList.contains("submit") ||
446+
el.dataset.suggestionSubmit === "" ||
447+
el.dataset.suggestionSubmit === "true",
443448
};
444449
}
445450

0 commit comments

Comments
 (0)