mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-02-17 13:20:52 +08:00
fix(data-table): change default sorter to place null values at the very top or bottom (#5284)
* Update CHANGELOG.en-US.md * Update CHANGELOG.zh-CN.md * fix(n-data-table): change default sorter to place null values at the very top or bottom --------- Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
parent
7d547a396b
commit
b44ffe58d6
@ -110,6 +110,7 @@
|
||||
- Fix rapid clicks on `n-date-input`'s buttons triggering a text select for the rest of the website.
|
||||
- Fix `n-auto-complete`'s autocomplete menu's unexpected open when clicking the clear icon with the input not focused, closes [#4658](https://github.com/tusen-ai/naive-ui/issues/4658).
|
||||
- Fix `n-input`'s `on-keyup` prop type, closes [#5101](https://github.com/tusen-ai/naive-ui/issues/5101)
|
||||
- Fix `n-data-table`'s default sorter to place null values at the very top or bottom, closes [#5281](https://github.com/tusen-ai/naive-ui/issues/5281).
|
||||
- Fix `n-popconfirm`'s action button should not be triggered multiple times,closes [#4687](https://github.com/tusen-ai/naive-ui/issues/4687).
|
||||
|
||||
### Features
|
||||
|
@ -112,6 +112,7 @@
|
||||
- 修复 `n-date-input` 的按钮快速点击时网站其余文本会被选中
|
||||
- 修复 `n-auto-complete` 在未聚焦状态下点击清除按钮时补全菜单意外打开的问题,关闭 [#4658](https://github.com/tusen-ai/naive-ui/issues/4658)
|
||||
- 修复 `n-input` 属性 `on-keyup` 类型,关闭 [#5101](https://github.com/tusen-ai/naive-ui/issues/5101)
|
||||
- Fix `n-data-table`'s default sorter to place null values at the very top or bottom, closes [#5281](https://github.com/tusen-ai/naive-ui/issues/5281).
|
||||
- 修复 `n-popconfirm` 操作按钮不应该被多次触发,关闭 [#4687](https://github.com/tusen-ai/naive-ui/issues/4687)
|
||||
|
||||
### Features
|
||||
|
@ -57,7 +57,11 @@ function getDefaultSorterFn (
|
||||
const value1 = row1[columnKey]
|
||||
const value2 = row2[columnKey]
|
||||
|
||||
if (typeof value1 === 'number' && typeof value2 === 'number') {
|
||||
if(value1 === null) {
|
||||
return -1
|
||||
} else if(value2 === null) {
|
||||
return 1
|
||||
} else if (typeof value1 === 'number' && typeof value2 === 'number') {
|
||||
return value1 - value2
|
||||
} else if (typeof value1 === 'string' && typeof value2 === 'string') {
|
||||
return value1.localeCompare(value2)
|
||||
|
Loading…
Reference in New Issue
Block a user