Skip to content

fix(chat): focus prompt after reveal - #7180

Open
anjola-adeuyi wants to merge 3 commits into
masterfrom
fix/fx-3936-focus-after-reveal
Open

fix(chat): focus prompt after reveal#7180
anjola-adeuyi wants to merge 3 commits into
masterfrom
fix/fx-3936-focus-after-reveal

Conversation

@anjola-adeuyi

@anjola-adeuyi anjola-adeuyi commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • wait for the Chat layout to be visibly revealed before focusing its prompt after reopening
  • ignore unrelated, infinite and already-visible animations while treating completed or canceled reveal animations as settled
  • cancel stale focus after closing, unmounting, replacing the prompt or starting a newer focus request
  • keep zero-motion and custom layouts immediate, with the same behavior in JavaScript and React

FX-3936

Testing

  • JavaScript and React wrapper and common Chat tests
  • Chromium and Firefox coverage for default, ongoing, unrelated paused, visible paused, finished and canceled reveal animations

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.

Copilot AI lite review requested due to automatic review settings August 19, 2026 12:03
@codacy-production

codacy-production Bot commented Aug 19, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 313 complexity

Metric Results
Complexity 313

View in Codacy

TIP This summary will be updated as you push new changes.

@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown
More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@7180

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@7180

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@7180

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@7180

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@7180

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@7180

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@7180

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@7180

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@7180

commit: 306d109

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/getActiveContainerAnimations helper 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.

Comment thread tests/e2e/playwright/specs/chat-focus.spec.ts Outdated
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

Size Change: +3.76 kB (+0.31%)

Total Size: 1.24 MB

📦 View Changed
Filename Size Change
packages/instantsearch.js/dist/instantsearch.development.js 305 kB +1.72 kB (+0.57%)
packages/instantsearch.js/dist/instantsearch.production.min.js 143 kB +886 B (+0.62%)
packages/react-instantsearch/dist/umd/ReactInstantSearch.min.js 115 kB +1.16 kB (+1.02%)
ℹ️ View Unchanged
Filename Size Change
packages/algolia-experiences/dist/algolia-experiences.development.js 179 kB 0 B
packages/algolia-experiences/dist/algolia-experiences.production.min.js 81.4 kB 0 B
packages/algoliasearch-helper/dist/algoliasearch.helper.js 44.3 kB 0 B
packages/algoliasearch-helper/dist/algoliasearch.helper.min.js 13.9 kB -1 B (-0.01%)
packages/instantsearch.css/components/ai-mode-button.css 1.75 kB 0 B
packages/instantsearch.css/components/autocomplete-min.css 4.31 kB 0 B
packages/instantsearch.css/components/autocomplete.css 4.66 kB 0 B
packages/instantsearch.css/components/button.css 1.96 kB 0 B
packages/instantsearch.css/components/chat-min.css 6.36 kB 0 B
packages/instantsearch.css/components/chat.css 6.83 kB 0 B
packages/instantsearch.css/components/filter-suggestions.css 1.88 kB 0 B
packages/instantsearch.css/themes/algolia-min.css 10.8 kB 0 B
packages/instantsearch.css/themes/algolia.css 11.5 kB 0 B
packages/instantsearch.css/themes/nova-min.css 10.9 kB 0 B
packages/instantsearch.css/themes/nova.css 11.6 kB 0 B
packages/instantsearch.css/themes/reset-min.css 1.3 kB 0 B
packages/instantsearch.css/themes/reset.css 1.38 kB 0 B
packages/instantsearch.css/themes/satellite-min.css 11.6 kB 0 B
packages/instantsearch.css/themes/satellite.css 12.6 kB 0 B
packages/react-instantsearch-core/dist/umd/ReactInstantSearchCore.min.js 68.1 kB -1 B (0%)
packages/vue-instantsearch/vue2/cjs/index.js 19.9 kB 0 B
packages/vue-instantsearch/vue2/umd/index.js 73.4 kB -6 B (-0.01%)
packages/vue-instantsearch/vue3/cjs/index.js 20.6 kB 0 B
packages/vue-instantsearch/vue3/umd/index.js 73.8 kB -6 B (-0.01%)

compressed-size-action

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@anjola-adeuyi
anjola-adeuyi requested review from a team, afrencalg and shaejaz and removed request for a team August 19, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants