Skip to content

Anchor the suggestion dropdown with Popover - #201

Merged
alex-rawlings-yyc merged 6 commits into
mainfrom
200-suggestion-dropdown-popover
Aug 6, 2026
Merged

Anchor the suggestion dropdown with Popover#201
alex-rawlings-yyc merged 6 commits into
mainfrom
200-suggestion-dropdown-popover

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This change is Reviewable

Summary by CodeRabbit

  • Accessibility

    • Improved suggestion dropdown accessibility with listbox semantics, expanded/collapsed state, active-option tracking, and focus retention.
    • Added support for accessible dialog identifiers, roles, and custom styling.
    • Improved focus restoration when suggestions open or close.
  • Bug Fixes

    • Improved dropdown anchoring and sizing during scrolling and window changes.
    • Ensured the active suggestion scrolls into view during keyboard navigation.
    • Prevented unintended focus changes when interacting with suggestions.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d9bdfa0-29c4-4234-9189-c870df65252c

📥 Commits

Reviewing files that changed from the base of the PR and between de6fe54 and da7dc9c.

📒 Files selected for processing (1)
  • __mocks__/platform-bible-react.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • mocks/platform-bible-react.tsx

📝 Walkthrough

Walkthrough

SuggestionDropdown now uses an anchored Popover in TokenChip. PopoverContent forwards accessibility props and supports cancelable close autofocus. Tests validate ARIA wiring, active descendants, scrolling, and focus retention.

Changes

Suggestion popover migration

Layer / File(s) Summary
PopoverContent forwarding contract
__mocks__/platform-bible-react.tsx
PopoverContent accepts and forwards optional id, role, and style props. Its close autofocus event is cancelable, and unprevented closure blurs the active element.
Popover-hosted suggestion list
src/components/SuggestionDropdown.tsx
SuggestionDropdown uses PopoverContent, removes manual positioning and dismissal logic, and renders focusable listbox options.
TokenChip integration and accessibility validation
src/components/TokenChip.tsx, src/__tests__/components/TokenChip.suggestions.test.tsx
TokenChip anchors the suggestion popover to the gloss input. Tests cover combobox/listbox ARIA relationships, active descendants, scrolling, and focus retention.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

  • sillsdev/interlinearizer-extension#200 — Covers the migration of SuggestionDropdown and TokenChip to the platform Popover.

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant TokenChip
  participant Popover
  participant SuggestionDropdown
  User->>TokenChip: Enter or navigate gloss suggestions
  TokenChip->>Popover: Open anchored popover
  Popover->>SuggestionDropdown: Render listbox content
  SuggestionDropdown->>TokenChip: Report active option or selection
  TokenChip->>User: Update ARIA state and retain input focus
Loading

Suggested reviewers: imnasnainaec

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: anchoring the suggestion dropdown with a Popover.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 200-suggestion-dropdown-popover

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Drops the hand-rolled positioning, scroll/resize listeners, and
close-on-scroll-out rule; the panel now tracks the gloss field wherever
the view scrolls it.
@alex-rawlings-yyc
alex-rawlings-yyc force-pushed the 200-suggestion-dropdown-popover branch from 44e4808 to d172f38 Compare August 5, 2026 17:45
@alex-rawlings-yyc
alex-rawlings-yyc marked this pull request as ready for review August 5, 2026 17:45
The panel is the popover's own element, so an li sits outside any list
and escapes Tailwind's ol/ul/menu list-style reset, growing a marker on
every row. The div needs an explicit tabIndex the li's non-interactive
implicit role was suppressing the check for.
coderabbitai[bot]

This comment was marked as outdated.

Comment thread src/components/SuggestionDropdown.tsx
Comment thread src/components/SuggestionDropdown.tsx
Comment thread src/components/SuggestionDropdown.tsx
Comment thread src/components/SuggestionDropdown.tsx Outdated

@imnasnainaec imnasnainaec 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.

@imnasnainaec reviewed all commit messages.
Reviewable status: 0 of 4 files reviewed, 6 unresolved discussions (waiting on alex-rawlings-yyc).

Also makes the popover mock's close sentinel honor preventDefault, so
the
close-focus test can fail when the handler stops suppressing it.

@alex-rawlings-yyc alex-rawlings-yyc left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@alex-rawlings-yyc made 6 comments.
Reviewable status: 0 of 4 files reviewed, 6 unresolved discussions (waiting on alex-rawlings-yyc and imnasnainaec).

Comment thread __mocks__/platform-bible-react.tsx
Comment thread src/__tests__/components/TokenChip.suggestions.test.tsx
Comment thread src/components/SuggestionDropdown.tsx
Comment thread src/components/SuggestionDropdown.tsx
Comment thread src/components/SuggestionDropdown.tsx
Comment thread src/components/SuggestionDropdown.tsx Outdated
Comment thread src/components/SuggestionDropdown.tsx Outdated
Comment thread src/components/SuggestionDropdown.tsx Outdated
Comment thread src/__tests__/components/TokenChip.suggestions.test.tsx Outdated

@imnasnainaec imnasnainaec 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.

@imnasnainaec reviewed 1 file and all commit messages, and resolved 4 discussions.
Reviewable status: 1 of 4 files reviewed, 3 unresolved discussions (waiting on alex-rawlings-yyc).

Swap the contradictory p-0/py-1 for px-0/py-1, name the assumption that
keeps the anchor span as wide as the gloss field, and drop the scroll
test's unread rect stub.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
__mocks__/platform-bible-react.tsx (1)

839-841: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Move the popover sentinels outside the listbox.

SuggestionDropdown sets role="listbox" on PopoverContent, then the mock wraps the test-only popover-close and popover-outside buttons inside that same element. Those buttons are no production options or outside-dismiss affordances, and they skew screen-reader/focus tests. Render them as siblings of the role-bearing content element or in a wrapper outside the role-bearing content itself.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@__mocks__/platform-bible-react.tsx` around lines 839 - 841, Update the mock’s
SuggestionDropdown rendering so the test-only popover-close and popover-outside
sentinel buttons are siblings of, or wrapped outside, the PopoverContent element
carrying role="listbox"; keep the actual suggestion content inside the listbox
and preserve both sentinel buttons’ behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@__mocks__/platform-bible-react.tsx`:
- Around line 839-841: Update the mock’s SuggestionDropdown rendering so the
test-only popover-close and popover-outside sentinel buttons are siblings of, or
wrapped outside, the PopoverContent element carrying role="listbox"; keep the
actual suggestion content inside the listbox and preserve both sentinel buttons’
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 32a24a7a-9a5e-426c-8d4a-94e8a3f52251

📥 Commits

Reviewing files that changed from the base of the PR and between b140d74 and de6fe54.

📒 Files selected for processing (3)
  • __mocks__/platform-bible-react.tsx
  • src/__tests__/components/TokenChip.suggestions.test.tsx
  • src/components/SuggestionDropdown.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/SuggestionDropdown.tsx
  • src/tests/components/TokenChip.suggestions.test.tsx

@imnasnainaec imnasnainaec 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.

@imnasnainaec reviewed 4 files and all commit messages, and resolved 3 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

@alex-rawlings-yyc
alex-rawlings-yyc merged commit 432c3b0 into main Aug 6, 2026
12 of 17 checks passed
@alex-rawlings-yyc
alex-rawlings-yyc deleted the 200-suggestion-dropdown-popover branch August 6, 2026 17:52
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.

Anchor the suggestion dropdown with platform Popover instead of hand-rolled positioning (platform-bible-react components Tier 4)

2 participants