Skip to content

DataTable: Wrong TypeScript definition for cell selection #8115

@MartinNiederl

Description

@MartinNiederl

Describe the bug

There are 3 interfaces that define selection specific properties for the DataTable component:

  • DataTablePropsSingle: single row selection
    • DataTableContextMenuSingleSelectionChangeEvent<TValue>
  • DataTablePropsMultiple: multiple rows selection
    • DataTableContextMenuMultipleSelectionChangeEvent<TValue>
  • DataTablePropsCell: cell selection (single or multiple)
    • DataTableSelectionCellChangeEvent<TValue>

The DataTableSelectionCellChangeEvent is used for both single and multiple cell selections.
However, the value property in the event type is defined as a single DataTableCellSelection<TValue>, even for multiple selections.
It should be an array of DataTableCellSelection<TValue> for multiple selections.

Same for the selection property in DataTablePropsCell, which is currently defined as a single DataTableCellSelection<TValue>, but should be an array for multiple selections.

I'm not sure if it is better to change the types to allow for both single and multiple selections in the same interface, or to create a separate interface for multiple cell selections as it is done for row selections.

tl;dr:

DataTableCellProps.selection and DataTableSelectionCellChangeEvent.value should be an array of DataTableCellSelection<TValue> for multiple selections, not a single DataTableCellSelection<TValue>.

Reproducer

No response

System Information

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 13.11 GB / 31.93 GB
  Binaries:
    Node: 22.16.0 - C:\nvm4w\nodejs\node.EXE
    npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD
    pnpm: 10.12.3 - C:\nvm4w\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (138.0.3351.55)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    primereact: ^10.9.6 => 10.9.6
    react: ^19.1.0 => 19.1.0 
    tailwindcss: ^4.1.10 => 4.1.11

Steps to reproduce the behavior

No response

Expected behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypescriptIssue or pull request is *only* related to TypeScript definition

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions