Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/dataviews/src/single-selection-checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ export default function SingleSelectionCheckbox( {
<CheckboxControl
className="dataviews-view-table-selection-checkbox"
__nextHasNoMarginBottom
checked={ isSelected }
label={ selectionLabel }
disabled={ disabled }
aria-disabled={ disabled }
checked={ isSelected }
onChange={ () => {
if ( disabled ) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we consider whether this behavior make sense for all usage of CheckboxControl and whether we should bake it in for any usage of the disabled prop? (Obviously not a blocker)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably makes sense for aria-disabled (it's handled automatically when using disabled).

Copy link
Member

Choose a reason for hiding this comment

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

When the checkbox is disabled, click or keyboard actions shouldn't trigger an actual change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently when a checkbox is aria-disabled, click and keyboard interactions will toggle the checkmark (visually at least). I don't think you'd ever want that, so it makes sense to add this to the component some how?

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking was more: automatically use aria-disabled and prevent onChange when disabled is passed. Like we do when __experimentalIsFocusable is true in buttons.

Copy link
Member

Choose a reason for hiding this comment

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

I added an issue for this at #59411. Ideally we would address it in the CheckboxControl component first, but if we don't have time I'm fine with cleaning up later.

As for the default focusability of a disabled component, I'm kind of leaning toward sticking to the standard browser behavior (which is to not be focusable). Of course we would also provide an opt-in prop to maintain focusability, as in Button.


if ( ! isSelected ) {
onSelectionChange(
data.filter( ( _item ) => {
Expand Down