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

fix: use 0 for falsy number progress values during sorting #1444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export default class NumberProgressColumn extends AbstractNumberColumn {
sort(mode, nextSorts) {
const factor = mode === 'DESC' ? -1 : 1
return (rowA, rowB) => {
const tmpA = rowA.data.find(item => item.columnId === this.id)?.value || null
const tmpA = rowA.data.find(item => item.columnId === this.id)?.value || 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the problem was the fact that when the row value was 0, we were assigning to null instead of just keeping 0. One 'problem' that still exist is if there are null rows (when user saves without setting a value), they are treated as 0. I imagine the use might expect all null rows to be at the bottom instead.
I also considered using ?? instead of ||, but this doesn't fix this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browser console says ?? should do ok:

Screenshot_20241107_225950

Unless the 0 was already casted so bool or such in value?

const valueA = parseInt(tmpA)
const tmpB = rowB.data.find(item => item.columnId === this.id)?.value || null
const tmpB = rowB.data.find(item => item.columnId === this.id)?.value || 0
const valueB = parseInt(tmpB)
return ((valueA < valueB) ? -1 : (valueA > valueB) ? 1 : 0) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
}
Expand Down
Loading