fix(chat): focus prompt after reveal - #7180
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 313 |
TIP This summary will be updated as you push new changes.
More templates
algoliasearch-helper
instantsearch-ui-components
instantsearch.css
instantsearch.js
react-instantsearch
react-instantsearch-core
react-instantsearch-nextjs
react-instantsearch-router-nextjs
vue-instantsearch
commit: |
There was a problem hiding this comment.
Pull request overview
This PR fixes Chat prompt focusing so that, when reopening Chat, focus moves to the prompt only after the Chat layout is visibly revealed (accounting for CSS animations), with cancellation safeguards to avoid stale focus attempts. It introduces a shared focusAfterReveal helper in instantsearch.js and wires it into both the JavaScript widget and the React wrapper, backed by unit/common/E2E coverage.
Changes:
- Add a shared
focusAfterReveal/getActiveContainerAnimationshelper to wait for relevant reveal animations before focusing. - Update the Chat widget (JS) and React Chat component to defer focus until reveal is settled and cancel stale focus requests.
- Add/extend common, unit, and Playwright E2E tests covering interrupted/paused/canceled/ongoing animation scenarios.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/playwright/specs/chat-focus.spec.ts | New E2E coverage for focus behavior across multiple animation states. |
| tests/common/widgets/chat/options.tsx | Adjust common tests to wait for prompt focus after opening with custom layouts. |
| packages/react-instantsearch/src/widgets/Chat.tsx | Defer prompt focus until reveal animations settle; cancel stale focus attempts. |
| packages/react-instantsearch/src/widgets/tests/Chat.test.tsx | Add regression test ensuring focus doesn’t fire after close interrupts reveal. |
| packages/instantsearch.js/src/widgets/chat/chat.tsx | Apply reveal-aware focus logic to the JS widget with request cancellation. |
| packages/instantsearch.js/src/widgets/chat/tests/chat.test.tsx | Add regression test mirroring interrupted reveal behavior in JS widget. |
| packages/instantsearch.js/src/lib/chat/focusAfterReveal.ts | New shared helper implementing reveal-aware focus logic based on active animations and computed style. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Size Change: +3.76 kB (+0.31%) Total Size: 1.24 MB 📦 View Changed
ℹ️ View Unchanged
|
Summary
FX-3936
Testing
Browser checks confirm that focus remains on the trigger while the layout is hidden, then moves to the prompt only after the layout is visible. No visual styling or public API changes.