Skip to content

fix(widget): keep focus in the popup on the consent notice and menu choices - #625

Merged
anurag629 merged 2 commits into
codercops:devfrom
bhushan4work:608
Nov 19, 2026
Merged

anurag629 merged 2 commits into
codercops:devfrom
bhushan4work:608

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

What does this change?

Fix the two places focus escaped the popup dialog.

  • With waitForConsent: true, opening the popup now focuses the consent notice, which gets tabindex="-1", so it is announced and Escape closes the chat. Inline mode keeps its existing behavior and does not take focus.
  • Choosing a header menu item by click, Enter or Space now returns focus to the More options button, matching Escape.

Added unit tests for both focus paths, updated the S17 and header menu e2e tests to assert focus, and added a patch changeset for @chatcops/widget.

Closes #608

How I tested this

Ran pnpm test:coverage, pnpm lint, pnpm size, and pnpm e2e; all pass.

AI assistance

None

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • pnpm api run and api/ committed if an exported type or option changed
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bhushan4work. Opening a popup that waits for consent now focuses the notice (it gets tabindex="-1"), so a screen reader reads it and Escape closes the chat, while an inline chat leaves focus alone. Choosing a menu item puts focus back on More options, the same as Escape. The unit tests check activeElement for both, and S17 now checks focus instead of setting it. I updated your branch with dev. All checks pass, including e2e.

@anurag629
anurag629 merged commit d569c86 into codercops:dev Nov 19, 2026
5 checks passed
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @bhushan4work.

@github-actions github-actions Bot added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Focus escapes the popup on the consent notice and after a header menu choice

2 participants