Bug: Clicking submit button does not trigger chat submission in Sidepanel Ask AI (@algolia/sitesearch)

Aperta
#30 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
javascript, typescript
Ambito
frontend

Direzione di ricerca

Inizia dal punto di ingresso documentato di vanilla JS sidepanel-askai e dalla build pubblicata dist/sidepanel-askai.min.js, quindi confronta i percorsi del pulsante e del tasto Enter nella demo ufficiale di CodeSandbox. Verifica che facendo clic su .ss-search-submit-chat-button la domanda venga inviata e venga effettuata la stessa richiesta che si ottiene premendo Enter, senza richiedere il workaround segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

In the sidepanel-askai experience (@algolia/sitesearch), clicking the chat
submit button (.ss-search-submit-chat-button) does not submit the question.
No network request is sent, and no console error is thrown. Submitting via
the Enter key works correctly. This is reproducible in Algolia's own official
demo for this component, not just in our implementation, so it does not
appear to be an integration-specific issue.

Package

@algolia/sitesearch, sidepanel-askai experience, vanilla JS build
(via https://unpkg.com/@algolia/sitesearch@latest/dist/sidepanel-askai.min.js)

Steps to reproduce
  1. Initialize SiteSearchSidepanelAskAI per the documented vanilla JS setup (container, applicationId, apiKey, indexName, assistantId, agentStudio: true).
  2. Open the sidepanel and type a question into the chat input.
  3. Click the submit button (the up-arrow icon, .ss-search-submit-chat-button).
Expected behavior

The question is submitted, identical to pressing Enter.

Actual behavior

Nothing happens. No request appears in the Network tab. No console errors.

Diagnostics already performed

Confirmed mousedown, mouseup, and click events all fire correctly on
the button itself when manually instrumented with addEventListener —
ruling out an overlay, z-index, or pseudo-element intercepting the click.
Confirmed the issue is not caused by our own site's custom JavaScript: it
reproduces with all custom scripts removed, and in a clean incognito
browser profile with no extensions.
Confirmed Enter-key submission on the same input works correctly every time.
Confirmed the issue reproduces in Algolia's own official SiteSearch +
Ask AI demo, not only in our implementation - https://codesandbox.io/p/github/algolia/sitesearch

Suspected cause (unconfirmed)

The widget appears to rely on native HTML form submission (a
inside a element) rendered via Preact.
Enter-key submission likely triggers the form's native submit event
directly, while the button's click does not appear to be wired to any
handler that produces the same effect. We have not been able to confirm this
against the unminified source.

Workaround currently in use

We are manually dispatching a submit event on the form when the button is
clicked, using event delegation so it survives panel re-renders:

jsdocument.addEventListener('click', (e) => {
  const button = e.target.closest('.ss-search-submit-chat-button');
  if (!button) return;
  const form = button.closest('search') || button.closest('form');
  if (!form) return;
  const input = form.querySelector('input');
  if (!input || !input.value.trim()) return;
  e.preventDefault();
  form.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
});

This resolves the issue on our end, but we wanted to flag it as we expect
other implementers will hit the same problem, and we'd prefer not to carry a
manual workaround indefinitely.

Environment

Webflow site using vanilla JS implementation of SiteSearch and AskAI
Browser: reproduced across multiple browsers - Chrome, Firefox, Safari
@algolia/sitesearch version: latest via unpkg

Lingua principale
TypeScript
Stelle
25
Fork
8
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di algolia/sitesearch

Tutte le issue di algolia/sitesearch

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.