-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Data Table default sorter broken when using null values #5281
Comments
If the naive-ui/src/data-table/src/use-sorter.ts Lines 53 to 67 in ef7279e
So in your case, when null is compared with other numeric values, it will return 0, which means it will maintain the original order. |
Thank you, I understand. I would like to discuss if this behavior is really desired or if this should be changed in the default sorter? In my opinion, columns with null values should be at the very bottom or top when sorting. |
The |
Yes, I saw that. Of course, it is convenient to be able to use your own sorter functions. How would you solve that with a custom sorter function without defining it every time? I would like to define it once globally and reference to it. But as far as I can see in the docs, only the whole row is passed to my function without knowing the actual column which makes it impossible to use it in that way. |
corresponding PR merged |
TuSimple/naive-ui version (版本)
2.34.4
Vue version (Vue 版本)
3.3.4
Browser and its version (浏览器及其版本)
Chrome (117.0.5938.92)
System and its version (系统及其版本)
MacOS (13.6)
Reappearance link (重现链接)
https://codesandbox.io/s/quirky-keller-3dhh9l
Reappearance steps (重现步骤)
Sort the "Bar" column ascending or descending -> Nothing happens
Expected results (期望的结果)
Rows should be sorted
Actual results (实际的结果)
Rows are not being sorted
Remarks (补充说明)
As soon as I remove the row with the null value, sorting works again as expected.
The text was updated successfully, but these errors were encountered: