Repository navigation
fix(widget): improve inline accessibility - #620
Conversation
anurag629
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
Merged, thanks @bhushan4work. |
What does this change?
Fixes inline widget accessibility for #615:
regions and update theiraria-labelwhen branding changes.Closes #615
How I tested this
Ran exactly:
Result: passed 2,557 tests passed, 65 skipped; no type errors.
Result: passed.
Result: passed
dist/chatcops.panel.jsis 19.01 kB gzip.Result: passed 97 passed, 21 skipped. Inline axe states and the
document.activeElementfocus assertion passed.AI assistance
None
Checklist
devpnpm -r build,pnpm testandpnpm -r typecheckpass locallypnpm changeset) if this changescore,widgetorserverpnpm apirun andapi/committed if an exported type or option changed