Skip to content

[checkbox] Ignore focus while disabled#4998

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/checkbox-disabled-focus-guard
Jun 11, 2026
Merged

[checkbox] Ignore focus while disabled#4998
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/checkbox-disabled-focus-guard

Conversation

@atomiks

@atomiks atomiks commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Disabled Checkbox could still set focused field state when focus was moved to it programmatically.

Root cause

Checkbox handled focus without checking disabled, unlike the related Switch and Radio controls.

Changes

  • Guarded Checkbox focus state updates while disabled.
  • Added coverage for disabled Checkbox not setting data-focused.

@atomiks atomiks added component: checkbox Changes related to the checkbox component. type: bug It doesn't behave as expected. labels Jun 10, 2026 — with ChatGPT Codex Connector
@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown

commit: ae06ac7

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 10, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+3B(0.00%) 🔺+3B(0.00%)

Details of bundle changes

Performance

Total duration: 1,315.51 ms +91.43 ms(+7.5%) | Renders: 50 (+0) | Paint: 1,983.26 ms +155.27 ms(+8.5%)

Test Duration Renders
Dialog mount (300 instances) 65.88 ms 🔺+17.19 ms(+35.3%) 1 (+0)
Popover mount (300 instances) 79.89 ms 🔺+13.87 ms(+21.0%) 1 (+0)

10 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit ae06ac7
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2a1c0c4ad3cf0008a40dc8
😎 Deploy Preview https://deploy-preview-4998--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks marked this pull request as ready for review June 10, 2026 07:43

atomiks commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Code Review (GPT-5.5)

Approve ✅ This is a narrow bug fix that correctly blocks disabled Checkbox focus state without expanding the component’s behavior surface.

1. Bugs / Issues (None)

I didn’t find any blocking or non-blocking issues in the branch diff.

2. Root Cause & Patch Assessment

The fix addresses the root cause directly: Checkbox.Root previously set Field focus state on every root focus event, even when the checkbox was disabled. Guarding setFocused(true) behind !disabled matches the existing Switch pattern and prevents disabled controls from exposing data-focused through Field state after programmatic focus.

3. Test Coverage Assessment

The added regression test covers the reported disabled-focus case at the component/state-attribute level. I also ran:

pnpm test:jsdom CheckboxRoot --no-watch
pnpm test:chromium CheckboxRoot --no-watch
git diff --check upstream/master...HEAD

All passed. GitHub status checks for the PR head are green as well.

@atomiks atomiks merged commit 747447c into mui:master Jun 11, 2026
23 checks passed
@atomiks atomiks deleted the codex/checkbox-disabled-focus-guard branch June 11, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: checkbox Changes related to the checkbox component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant