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: sortOrder property in DataTableStateEvent always has value of 1 #7092

Open
karkianish opened this issue Aug 29, 2024 · 3 comments
Labels
Type: Bug Issue contains a defect related to a specific component.

Comments

@karkianish
Copy link

Describe the bug

The value of sortOrder property in DataTableStateEvent is always 1. The expected behavior is the value should vary between 1 | 0 | -1 depending on sort order.

Reproducer

https://stackblitz.com/edit/a6xx6a?file=src%2FApp.jsx

System Information

System:
OS: Windows 11 10.0.22631
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-1370P
Memory: 8.72 GB / 31.66 GB
Binaries:
Node: 21.6.1 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
npm: 10.2.4 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD
Browsers:
Edge: Spartan
npmPackages:
primereact: ^10.8.2 => 10.8.2
react: ^18 => 18.2.0
tailwindcss: ^3.4.7 => 3.4.7

Steps to reproduce the behavior

  • Add a DataTable component with at least one sortable column
  • provide callback to the onSort callback for the data table
  • in the callback, console.log the event args
  • in the rendered UI, click column header to trigger sorting
  • observe the value of sortOrder property in console (logged from step 3)

Expected behavior

The value of sortOrder property should alternate 1 | 0 | -1 to indicate asc/desc sort order.

@karkianish karkianish added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 29, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 29, 2024
@melloware
Copy link
Member

melloware commented Aug 31, 2024

From looking at the source code if you use onSort it looks like it thinks you are in Cotrolled mode you are controlling the sorting paging and filtering where without it the table controls it all internally.

So its just returning your current original sort value on the column back to you.

@karkianish
Copy link
Author

@melloware - thanks for looking into it. I feel that the eventargs should be populated accurately and users should get to decide how sort will be handled with available information. The fieldname is populated correctly in the same eventargs object.

ps - since the issue is still categorized as Bug, I am assuming your comment above is giving more info about the problem rather than advocating the current behavior not being an issue.

@melloware
Copy link
Member

Correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

No branches or pull requests

3 participants
@karkianish @melloware and others