-
Notifications
You must be signed in to change notification settings - Fork 24
fix(Table): Make checkbox selection interactive and fix click handling #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(Table): Make checkbox selection interactive and fix click handling #17
Conversation
- Add indeterminate prop to Table.CheckHead and Table.CheckCell - Fix checkbox click handling by removing onClick stopPropagation that was interfering with Base UI's internal click handling - Refactor TableSelectedRowDemo and TableFullDemo with proper React state management for interactive row selection - Header checkbox now shows indeterminate state when some rows selected - Regenerate component registry
- Wrap checkbox in span with stopPropagation to prevent double-toggle when clicking directly on the checkbox - Add w-10 (40px) default width to TableCheckCell and TableCheckHead so checkbox columns are properly sized without needing colgroup - Add state management to TableWithCheckboxDemo - Remove redundant colgroup width from TableFullDemo
Add a DropdownMenu to the DotsThree button with View, Edit, and Delete options
Remove hacky span wrapper with stopPropagation. Instead: - Remove cell onClick handler entirely - Use CSS pseudo-element (before:-inset-3) to expand checkbox hit area - Only onCheckedChange handles clicks - no event bubbling issues This is cleaner and matches TanStack Table's approach.
While it may seem like you’re passing selection state twice, this is a intentional choice to keep the Table component stateless and presentational. By decoupling the visual highlight from the functional checkbox, we provide developers with full control. Automated syncing (checking the box when the row is "selected") breaks in complex scenarios—specifically when a single row contains multiple independent actions. For example, in a Permissions Matrix, a row shouldn't be "selected" just because one of several capability checkboxes is active: |
Summary
indeterminateprop support toTable.CheckHeadandTable.CheckCellw-10(40px) width to checkbox cellscheck.mov
Problem
The Table component demos at https://kumo-ui.com/components/table/ had non-functional checkboxes:
Solution
Component changes (
table.tsx)indeterminateprop toTable.CheckHeadandTable.CheckCellfor partial selection statew-10default width to checkbox cells for consistent sizingbefore:-inset-3) to expand the checkbox hit area without needing wrapper hacksDemo changes (
TableDemo.tsx)useState<Set<string>>) to all checkbox demosonValueChangehandlers for interactive selectionindeterminatestate to header checkboxesOpen Question
Is the
variant="selected"API onTable.Rowweird? Would a boolean make more sense here?Should we consider:
selectedboolean prop onTable.Row?CheckCellchild?Testing
/components/table/on the docs site