[Bug]: CheckBox is keyboard-inaccessible (display: none), missing focus indicators, and lacks uncontrolled state support

未关闭
#1,453 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@atanunath66-stack 已经在做这个了。

开始于 2026年11月24日。

  • #1462 来自 @atanunath66-stack —— 未关闭

评估

难度
3/5
预计耗时
半天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript, react

调研方向

Start in packages/ui-elements at CheckBox.js, where the <input> is hidden with style={{ display: 'none' }}, and read CheckBox.styles.js for the outline: none rule; the story to update lives in CheckBox.stories.js. Reproduce first with cd packages/ui-elements && npx storybook dev -p 6006, tabbing through the default story to confirm the checkbox is skipped. Done means the input stays in the tab order and accessibility tree (visually-hidden CSS rather than display: none), a :focus-visible ring using theme.colors.ring appears, Space toggles it, defaultChecked works uncontrolled, and the jsx-a11y suppression is removed.

由索引模型根据 Issue 内容生成。

描述

bug
Description:

The CheckBox component in @embeddedchat/ui-elements has several accessibility and usability compliance issues:

  1. Inaccessible to Keyboard & Assistive Technologies (WCAG 2.1.1, WCAG 4.1.2):
    The underlying <input type="checkbox"> is hidden using style={{ display: 'none' }} in CheckBox.js. In all modern browsers, display: 'none' completely removes the input from the accessibility tree and eliminates it from the keyboard Tab order. Consequently:

    • Keyboard users cannot tab to the checkbox or toggle it using Space.
    • Screen readers completely skip it.
    • The accessibility linter warning was suppressed with // eslint-disable-next-line jsx-a11y/label-has-associated-control.
  2. Missing :focus-visible Outline (WCAG 2.4.7 Level AA):
    CheckBox.styles.js sets outline: none; without providing an accessible :focus-visible ring when the checkbox receives focus.

  3. Lacks Uncontrolled Mode & Interactive State Handling:
    CheckBox.js does not manage internal state when used as an uncontrolled input (defaultChecked), and strictly binds to checked={checked}. When rendered in Storybook or when used without external controller state, the checkbox is completely frozen and does not toggle on click or change.


Steps to reproduce:
  1. Start Storybook: cd packages/ui-elements && npx storybook dev -p 6006
  2. Open http://localhost:6006/iframe.html?id=components-checkbox--default&viewMode=story
  3. Click on the canvas and press Tab — observe that the checkbox is completely skipped and cannot receive keyboard focus.
  4. Press Space — observe that it cannot be toggled via keyboard.
  5. Inspect the DOM in browser DevTools: observe <input type="checkbox" style="display: none;"> and that the Accessibility pane lists the input as not exposed to the accessibility API.
  6. Click the checkbox in the story — observe that it does not toggle because state is locked without uncontrolled support.

Expected behavior:
  • The native <input type="checkbox"> should use accessible visually-hidden CSS (e.g. position: absolute; opacity: 0; pointer-events: none;) instead of display: 'none', keeping it in the DOM accessibility tree and tab order.
  • The checkbox should display a visible :focus-visible outline matching theme.colors.ring when focused via keyboard.
  • Pressing Space should toggle the checkbox.
  • CheckBox should support both controlled (checked + onChange) and uncontrolled (defaultChecked) patterns.
  • The Storybook story should be interactive.

Proposed Solution:

I would like to resolve this in @embeddedchat/ui-elements:

  • Replace display: 'none' with standard visually-hidden CSS.
  • Add :focus-visible focus ring styles in CheckBox.styles.js.
  • Add support for both controlled (checked) and uncontrolled (defaultChecked / internal state) usage.
  • Remove the disabled jsx-a11y/label-has-associated-control linter suppression.
  • Update CheckBox.stories.js to allow interactive toggling.

May I be assigned this issue?

主要语言
JavaScript
星标
171
派生
421
平均合并
3 天 6 小时
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

RocketChat/EmbeddedChat 的其他 Issue

查看 RocketChat/EmbeddedChat 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。