Repository navigation
Closed
Labels
enhancementNew feature or request
Milestone
Description
Motivation
The current table selection plugin (useXDSTableSelection) supports individual row toggle and select-all. Real-world table interactions also need range selection (shift-click) and additive selection (ctrl/cmd-click).
Proposed behavior
Shift-click (range select)
- User clicks row A, then shift-clicks row B
- All rows between A and B become selected (inclusive)
- Previous selection is replaced by the range
Ctrl/Cmd-click (additive toggle)
- User ctrl-clicks (or cmd-click on Mac) a row
- That row toggles without affecting other selections
- This is the current default behavior — but should be explicit when modifier is held
Click (no modifier)
- Selects only the clicked row, deselecting all others
- This would be a behavior change from current (which toggles)
Select-all checkbox
- Unchanged — toggles all selectable rows
API changes
The useXDSTableSelection hook config would need:
interface UseXDSTableSelectionConfig<T> {
// ...existing props
/** Selection mode. @default "toggle" */
selectionMode?: "toggle" | "standard";
}toggle(current default): each click toggles that row, no modifier key behaviorstandard: click = single select, shift = range, ctrl/cmd = additive toggle
Alternatively, the hook could always support modifier keys and let the onSelectItem callback receive modifier state:
onSelectItem: (event: {
item: T;
isSelected: boolean;
shiftKey: boolean;
metaKey: boolean; // cmd on Mac, ctrl on Windows
}) => void;This lets consumers implement their own range logic, keeping the hook simple.
Implementation considerations
- Need to track the "anchor" row (last clicked without shift) for range selection
- Range selection needs access to the full data array to determine which rows are between anchor and target
- The hook may need a
dataprop orgetItemIndexcallback for range calculation - Keyboard support: Shift+Arrow for extending selection
Depends on
- Table: component-based styling + selection plugin #123 (table selection plugin — base implementation)
- Table Plugins #96 (table plugins)
Related
- WAI-ARIA grid pattern recommends shift/ctrl selection for data grids
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
cixzhang commentedon Mar 26, 2026
Merged into #719 (Cindy's Components — Table section). Range/modifier key selection tracked there.