Skip to content

fix(widget): improve inline accessibility - #620

Merged
anurag629 merged 3 commits into
codercops:devfrom
bhushan4work:615
Nov 17, 2026
Merged

anurag629 merged 3 commits into
codercops:devfrom
bhushan4work:615

Conversation

@bhushan4work

@bhushan4work bhushan4work commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change?

Fixes inline widget accessibility for #615:

  • Inline pre-chat forms no longer autofocus, including after consent; popup forms retain autofocus.
  • Inline panels are named regions and update their aria-label when branding changes.
  • Inline light, dark, and RTL states now have axe coverage for suggestions, sourced replies, retry errors, and pre-chat forms, including no focus on the widget after page load.

Closes #615

How I tested this

Ran exactly:

pnpm test:coverage

Result: passed 2,557 tests passed, 65 skipped; no type errors.

pnpm lint

Result: passed.

pnpm size

Result: passed dist/chatcops.panel.js is 19.01 kB gzip.

pnpm e2e

Result: passed 97 passed, 21 skipped. Inline axe states and the document.activeElement focus assertion passed.

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, nearly there. The form gets autoFocus: false in inline mode, the inline panel is a region named in renderHeader() so update({ branding }) renames it, and the unit tests cover the consent path, the popup form and the rename. The panel is at 19.01 of its 19.2 kB.

One test can't catch what it's there for. expectInlineUnfocused() (e2e/tests/states.spec.ts:61-66) uses expect.poll, which passes as soon as the check is true. In the pre-chat test at line 339 that's right after the form shows up, before the form's 100 ms focus timer (packages/widget/src/dom/prechat-form.ts:75) has run, so it would pass on dev too. Wait past the timer, then check once:

async function expectInlineUnfocused(page: Page) {
  await page.waitForTimeout(200);
  expect(await page.evaluate(() => {
    const host = document.querySelector('.chatcops-root');
    return document.activeElement !== host && host?.shadowRoot?.activeElement === null;
  })).toBe(true);
}

The CI run on this head has expired, so your push will start a fresh one.

@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. expectInlineUnfocused() now waits past the form's 100 ms timer before it checks, so the inline pre-chat test fails if the form takes focus. With the region name and the autoFocus change from before, that covers #615. All checks pass, including e2e.

@anurag629
anurag629 merged commit 99701ee into codercops:dev Nov 17, 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 17, 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.

Inline chat: stop taking focus on page load, give it a name, and check it with axe

2 participants