Skip to content

Commit fbdc974

Browse files
committed
Update CLAUDE.md; add checkbox single selection example
1 parent 8442b58 commit fbdc974

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ New in v0.4.5.9000
1414

1515
## Development Workflow
1616

17-
1. **Update design docs**: When using Plan Mode or for major features, write planning and design docs into the `design/` directory. Use `design/virtual-scrolling/` as a model. Ensure that features consider accessibility (targeting WCAG 2.2 at a minimum) and include a test plan. Also create an Rmd file with examples of different test cases. Use mtcars dataset for examples unless another dataset is more appropriate.
17+
1. **Update design docs**: When using Plan Mode or for major features, write planning and design docs into the `design/` directory. Use `design/virtual-scrolling/` as a model. Ensure that features consider accessibility (targeting WCAG 2.2 at a minimum) and include a test plan. Also create an Rmd file with examples of different test cases. Use MASS::Cars93 or mtcars datasets for examples unless another built-in R dataset is more appropriate.
1818
2. **Make changes**
1919
3. **Document R API**: Run `devtools::document()` in R when making any changes to the R API (roxygen comments).
2020
4. **Format**: Format JavaScript code using `prettier`.

design/js-row-selection-api/js-row-selection-api-test.Rmd

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,32 @@ tagList(
674674
elementId = "filtered-table"
675675
)
676676
)
677+
```
678+
679+
### Single selection with custom checkboxes
680+
681+
Expected: Checkboxes work with single selection mode. Clicking a checkbox selects that row and deselects any previously selected row.
682+
683+
```{r}
684+
reactable(
685+
MASS::Cars93[1:6, c("Manufacturer", "Model", "Type", "Price")],
686+
selection = "single",
687+
onClick = "select",
688+
columns = list(
689+
# Hide the default selection column
690+
.selection = colDef(show = FALSE),
691+
# Add a custom checkbox column
692+
Manufacturer = colDef(
693+
html = TRUE,
694+
cell = JS("function(cellInfo) {
695+
const checked = cellInfo.selected ? 'checked' : ''
696+
return `<label style=\"display: flex; align-items: center; gap: 8px\">
697+
<input type=\"checkbox\" ${checked} onclick=\"event.stopPropagation(); cellInfo.toggleRowSelected()\">
698+
${cellInfo.value}
699+
</label>`
700+
}")
701+
)
702+
),
703+
elementId = "checkbox-single"
704+
)
677705
```

0 commit comments

Comments
 (0)