Repository navigation
fix(js): trap focus in detached mode - #1374
Merged
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 29 |
TIP This summary will be updated as you push new changes.
Contributor
Author
|
Added coverage for editable footer controls, including explicit |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Ordinary Tab can still escape the modal under Safari’s default keyboard-navigation setting.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds detached-mode focus trapping while preserving native keyboard navigation and Escape handling.
Changes:
- Wraps focus at detached-container boundaries.
- Adds coverage for dynamic controls, editable elements, cleanup, and Escape.
| File | Description |
|---|---|
packages/autocomplete-js/src/autocomplete.ts |
Implements detached-mode keyboard handling. |
packages/autocomplete-js/src/__tests__/detached.test.ts |
Adds focus-trap regression tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Drop the Safari focus guards, contenteditable handling and the inert/visibility filtering, in line with the DocSearch approach. Keep the Tab wrap, Escape via the core handler and Ctrl/Cmd+Tab passthrough. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Haroenv
approved these changes
Oct 7, 2026
More templates
@algolia/autocomplete-core
@algolia/autocomplete-js
@algolia/autocomplete-plugin-algolia-insights
@algolia/autocomplete-plugin-query-suggestions
@algolia/autocomplete-plugin-recent-searches
@algolia/autocomplete-plugin-redirect-url
@algolia/autocomplete-plugin-tags
@algolia/autocomplete-preset-algolia
@algolia/autocomplete-shared
@algolia/autocomplete-theme-classic
commit: |
Contributor
|
thank you @minwookshin ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fixes #588. Keep keyboard focus inside the detached search dialog and restore it to the search button when the dialog closes. Native Tab movement is preserved between controls; focus guards also contain Safari's ordinary Tab navigation when it skips buttons and links. Escape uses the core handler so pending requests are cancelled. The trap follows dynamic template controls and is removed on update/destroy, with no new dependency or opt-in.
Result