Skip to content

fix(widget): validate on submit and focus first invalid field - #622

Merged
anurag629 merged 3 commits into
codercops:devfrom
bhushan4work:614
Nov 18, 2026
Merged

anurag629 merged 3 commits into
codercops:devfrom
bhushan4work:614

Conversation

@bhushan4work

@bhushan4work bhushan4work commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change?

  • Keeps the pre-chat form submit button enabled at all times.
  • On submit (via button click or Enter in a text field), validates all fields, displays all errors, and moves focus to the first invalid field.
  • Hides the required * marker from screen readers using aria-hidden="true".
  • Removes unused updateSubmitState() and .cc-prechat-submit:disabled CSS rule.
  • Updates documentation in website/src/content/docs/widget/pre-chat-form.mdx.
  • Updates unit tests in prechat-form.test.ts and E2E state tests in states.spec.ts.

Closes #614

How I tested this

Ran the verification checks locally:

  • pnpm vitest run --project @chatcops/widget prechat-form (22/22 passed)
  • pnpm test:coverage (142 test files passed, coverage thresholds met)
  • pnpm lint (passed without errors)
  • pnpm size (pre-chat form chunk 1.78 kB, within 2 kB limit)
  • pnpm e2e (all 97 functional and state tests passed, 21 visual tests skipped locally on macOS)

CI run verification:

  • All functional and state e2e tests passed (115/118 passed in CI).
  • The only failures in CI are the 3 visual baseline checks for S5 (s5-prechat-light.png, s5-prechat-dark.png, s5-prechat-rtl.png), which is the expected visual baseline change since the Start Chat button is now enabled (previously rendered disabled at 50% opacity). Per issue Pre-chat form: let visitors press Start Chat and see what's missing #614 and CONTRIBUTING.md, this baseline is updated by maintainers via the "Update screenshots" workflow.

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

@bhushan4work

Copy link
Copy Markdown
Collaborator Author

Note on CI e2e:
All 115 functional, state, and accessibility tests pass. The only 3 failures in CI are the visual screenshot tests for S5 (s5-prechat-light.png, s5-prechat-dark.png, and s5-prechat-rtl.png), which is the expected visual change because the submit button is now enabled (previously rendered disabled with 50% opacity).

As noted in issue #614 and CONTRIBUTING.md, contributor PRs from forks cannot run the Update screenshots workflow, so the baseline screenshots are updated by maintainers via the workflow.

@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. Start Chat stays enabled, so Tab reaches it and Enter in a field submits the form. A failed submit shows every error and moves focus to the first invalid field, and the * is hidden from screen readers next to aria-required. The unit tests check where focus goes, and S5 presses Start Chat on the empty form and runs axe.

I added the new S5 screenshots from the Update screenshots workflow. Start Chat is at full color now, and they also pick up the header's "..." menu from #505, which the old images were made before. I updated your branch with dev too. All checks pass, including e2e.

@anurag629
anurag629 merged commit 524f5e6 into codercops:dev Nov 18, 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 18, 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.

Pre-chat form: let visitors press Start Chat and see what's missing

2 participants