primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.97k stars 1.06k forks source link

DataTable: cellSelection type doesn't allow boolean values, only false or undefined #6376

Closed gcodecraft closed 7 months ago

gcodecraft commented 7 months ago

Describe the bug

Trying to implement a DataTable that triggers an action when I only select/click on a specific cell instead of the entire row, I found from the documentation that you enable this functionality by setting cellSelection. Looking into the datatable.d.ts file I see that this is:

    /**
     * Whether to cell selection is enabled or not.
     * @defaultValue false
     */
    cellSelection?: false | undefined;

Basically it does not allow setting cellSelection to true. The documentation says the same thing here.

I do not thing it's intended as if I //@ts-ignore this I am able to click the cells and launch the aforementioned action. Shouldn't the type be cellSelection?: boolean | undefined so it allows selecting a single cell?

P.S. (LE) I can contribute with the type fix if it's up for grabs :)

Thank you!

Reproducer

No response

PrimeReact version

10.6.3

React version

18.x

Language

TypeScript

Build / Runtime

Next.js

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

melloware commented 7 months ago

Thanks for reporting PR submitted!