-
Notifications
You must be signed in to change notification settings - Fork 142
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
[DataGrid] onSort causes first sort in DataGrid to not work #3197
Comments
hey @cgerein i tried to recreate this, but in your example and locally i found that adding can you verify that what i'm seeing is correct and can you clarify what your expected behavior is? |
Maybe be worth pointing the documentation to |
Hey, thanks for taking a look. I'm still seeing the issue with it in that codesandbox in the description. Essentially what I was seeing there and locally was that the first click you did to sort a column would be called with ASC, but the column state wouldn't change. By that I meant that the column header wouldn't update the sort state. Once you clicked the header a second time it shows the ascending icon properly, but is also still passing ASC to the My expected behaviour would be that clicking twice on a column header doesn't pass |
ok i see what you're saying. let me verify that this is an issue on our end and not with the underlying react table library. |
hey @cgerein just to give a quick update- i've been investigating this, but i haven't been able to find a conclusive reason for why this is happening. i think this may be put on hold for a bit because there are some more pressing issues, but we're still looking into this. |
We've been investigating TanStack Table, a third-party, open-source offering, which provides extensive data table capabilities surpassing what our Carbon Datagrid offers. It provides much more flexibility and customization. TanStack Table is headless which means it can easily be added alongside Datagrid component in your product or application. The benefits of more flexibility for product teams and less maintenance for Carbon makes it a win win. Lastly, it is available in multiple frameworks including React and Web Component so it provides an option to non-React product teams. For these reasons, we have decided to transition from building our own custom table component to using an example-based approach with TanStack Table. Datagrid will still exist in our library for existing teams but we are announcing the deprecation* of the Datagrid component in v2.54.0 release so teams can begin to work through the transition. Details about how to use both Datagrid and TanStack together can be found here. *Deprecation means that no new features will be added however sev 1 and sev 2 bugs will be supported. |
What package(s) are you using?
Detailed description
Passing a custom sort function to
useDataGrid()
withonSort
causes the first sort you try to do to not change the actual sort state on the column, but theonSort
function will still be called. This will cause onSort to call with the id and sort order you would expect, but the DataGrid will still show the previous order. Any clicks/changes to column order after the first click works how you would expect it to."@carbon/ibm-products": "2.1.2"
Steps to reproduce the issue
onSort
function to the DataGrid stateonSort
function again with the same parameters, and will properly set the columns sort stateHere's an example of the issue
https://codesandbox.io/p/sandbox/tender-northcutt-5lw2vc?file=%2Fsrc%2FExample%2FExample.jsx%3A9%2C24
Additional information
The text was updated successfully, but these errors were encountered: