adobe / adobe/react-spectrum

Custom styled checkbox not working correctly when rendered as a selection checkbox in a table

Open
#2,383 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

# 🐛 Bug Report
When using a custom-styled checkbox (useCheckbox) as a selection checkbox in a table (useTable), it seems to get toggled twice so the row will never be selected. And for the (de)select all checkbox it seems to not getting triggered at all.

## 🤔 Expected Behavior
To function the same as a checkbox without custom styling.

## 😯 Current Behavior
The styled checkboxes are triggered twice and the select-all checkbox is not triggered at all. Whereas the non styled checkboxes are working fine. I made a reproduction of this issue based on the example snippets of the useTable and useCheckbox docs.
[Sandbox here](https://codesandbox.io/s/clever-haze-e6x6d)

## 💁 Possible Solution

## 🔦 Context
For our project, we need to have different styled checkboxes than the standard ones. But we want to have the features that this library brings, so that's why we use the useChecbox hook and add styles as shown in the examples.

## 💻 Code Sample
https://codesandbox.io/s/clever-haze-e6x6d

## 🌍 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| react-spectrum | latest
| Browser | chrome, firefox, safari - all latest
| Operating System | macos - latest

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.