Skip to content
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

DataTable: onRowToggle event returns the wrong type for the data property #3127

Closed
saulodias opened this issue Aug 2, 2022 · 1 comment · Fixed by #3128 or #3129
Closed

DataTable: onRowToggle event returns the wrong type for the data property #3127

saulodias opened this issue Aug 2, 2022 · 1 comment · Fixed by #3128 or #3129
Assignees
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@saulodias
Copy link
Contributor

saulodias commented Aug 2, 2022

Describe the bug

When clicking the row expand button, the onRowToggle event will log an object of the type DataTableExpandedRows, where the keys are the dataKeys of the toggled rows, and the value is a boolean that says whether the rows are toggled or not when it should log an array of data keys like the typed value suggests.

image

By the way, it only ever shows the ids of the rows that are toggled, so the value is always true, hence the suggestion. As the expected type in the d.ts would make most implementations easier without the need to use the Object. keys() method which is usually what most people want, the keys of the toggled values.

But just making the DataTableRowToggleParams['data'] equals to DataTableExpandedRows, would fix the issue.

Reproducer

https://codesandbox.io/s/epic-sunset-xmuhit?file=/src/demo/DataTableRowExpansionDemo.tsx

PrimeReact version

8.3.0

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome 103.0.5060.134

Steps to reproduce the behavior

  1. Click the row expand button.
  2. The console will log an object of the type Record<string | number, boolean>, where the keys are the dataKeys of the toggled rows, and the value is a boolean that says whether the rows are toggled or not. The problem is that it only ever shows the ids of the rows that are toggled, so the value is always true.

So it doesn't even make sense to have an object for that. A list containing the data keys of the toggled rows makes more sense.

Expected behavior

The console will log an object of the type Array containing the data keys of the toggled rows makes more sense. Which could be the any[] that the type DataTableRowToggleParams already specifies for the data parameter.

@saulodias saulodias added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: Bug Issue contains a defect related to a specific component. labels Aug 2, 2022
melloware added a commit to melloware/primereact that referenced this issue Aug 2, 2022
@melloware melloware added Typescript Issue or pull request is *only* related to TypeScript definition and removed Type: Bug Issue contains a defect related to a specific component. Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 2, 2022
@melloware melloware self-assigned this Aug 2, 2022
@melloware melloware added this to the 9.0.0 milestone Aug 2, 2022
@melloware
Copy link
Member

Good catch, can you review my PR please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
3 participants