eliminacion masiva y selector mas inteligente para mostrar informacion y deseleccionarse
This commit is contained in:
@@ -156,15 +156,18 @@
|
||||
onclick={(e) => {
|
||||
if ((e.target as HTMLElement).closest('input[type="checkbox"]')) return;
|
||||
const rowId = getRowIdValue(row.original);
|
||||
if (rowId !== null) {
|
||||
const isSelected = selectedIds.includes(rowId);
|
||||
if (isSelected) {
|
||||
onSelectedIdsChange?.(selectedIds.filter((id) => id !== rowId));
|
||||
} else {
|
||||
// El id clickeado va primero para que el cuadro informativo lo muestre
|
||||
onSelectedIdsChange?.([rowId, ...selectedIds.filter((id) => id !== rowId)]);
|
||||
}
|
||||
if (rowId === null) return;
|
||||
// Click sobre la fila activa (la del frente) la deselecciona.
|
||||
// Click sobre cualquier otra fila la trae al frente (mostrar su info).
|
||||
if (selectedIds[0] === rowId) {
|
||||
onSelectedIdsChange?.(selectedIds.filter((id) => id !== rowId));
|
||||
return;
|
||||
}
|
||||
if (selectedIds.includes(rowId)) {
|
||||
onSelectedIdsChange?.([rowId, ...selectedIds.filter((id) => id !== rowId)]);
|
||||
return;
|
||||
}
|
||||
onSelectedIdsChange?.([rowId, ...selectedIds]);
|
||||
}}
|
||||
ondblclick={() => onRowDoubleClick?.(row.original)}
|
||||
class="cursor-pointer hover:bg-muted/50 transition-colors {row.getIsSelected() ? 'bg-primary/10' : ''}"
|
||||
|
||||
Reference in New Issue
Block a user