Skip to content

Components: Add disabled prop to CheckBoxControl - #69726

Closed
im3dabasia wants to merge 1 commit into
WordPress:trunkfrom
im3dabasia:try/add-disabled-prop-checkboxcontrol
Closed

im3dabasia wants to merge 1 commit into
WordPress:trunkfrom
im3dabasia:try/add-disabled-prop-checkboxcontrol

Conversation

@im3dabasia

Copy link
Copy Markdown
Contributor

What?

Adds support for disabled state in CheckboxControl.
Closes #59411

Why?

Issue #59364 identified the need for a disabled state on CheckboxControl for better accessibility and user experience in forms.

How?

  1. Added styling for for the disabled state
  2. Ensured onChange handler is bypassed when aria-disabled is true

Testing Instructions

  1. Run npm run storybook:dev
  2. Navigate to the CheckboxControl component
  3. Test different disabled states and verify styling
  4. Ensure disabled checkboxes cannot be toggled
  5. Test keyboard navigation with both regular and focusable disabled checkboxes

Screencast

Screen.Recording.2025-03-27.at.3.23.01.PM.mov

@im3dabasia
im3dabasia requested a review from ajitbohra as a code owner March 27, 2025 09:56
@github-actions

github-actions Bot commented Mar 27, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @mikeyarce.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: mikeyarce.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components Needs Design Feedback Needs general design feedback. labels Mar 27, 2025
@mirka
mirka requested a review from a team June 3, 2025 11:50
@jasmussen

Copy link
Copy Markdown
Contributor

This feels valid to me, though perhaps the text should look disabled too? CC: @jameskoster @ciampo

@jameskoster

Copy link
Copy Markdown
Contributor

Agree it's valid, but I think we should avoid opacity if possible. We can potentially mimic the disabled styles in the Button component here.

though perhaps the text should look disabled too?

I'd probably say we should do that only if we're prepared to apply the same treatment across all controls.

@@ -27,6 +27,7 @@ const meta: Meta< typeof CheckboxControl > = {
control: false,
},
help: { control: { type: 'text' } },
disabled: { control: { type: 'boolean' } },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to manually set this control, Storybook should infer it automatically from the types.

@ciampo

ciampo commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

If we want to be consistent with base-ui (which will power next gen of components in the @wordpress/ui package), their checkbox only has a disabled prop, which fully disables the input and makes it non-focusable (ie it uses disabled, not aria-disabled).

Do we think there is value in allowing checkboxes and other form controls to be focusable while disabled? cc @mirka

@mirka

mirka commented Mar 9, 2026

Copy link
Copy Markdown
Member

Do we think there is value in allowing checkboxes and other form controls to be focusable while disabled?

I don't think I've run into a use case yet, so no immediate plans to do so. It's probably fine to not support focusableWhenDisabled for form controls, as it's mostly a button concern.

@ciampo

ciampo commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Right, let's change the implementation to use disabled instead of aria-disabled, which should also simplify the code (ie. no need to early return on the onChange listener)

@mirka

mirka commented Apr 16, 2026

Copy link
Copy Markdown
Member

Closing this out now since the original issue was closed already. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Design Feedback Needs general design feedback. [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CheckboxControl: Add disabled state

6 participants