Skip to content

Issues when sortingFn is 'auto' and number of records is less than 10 #4908

@hviranicitco

Description

@hviranicitco

Describe the bug

When you have less than 10 records and for a column if sortingFn is 'auto' which is default. The sorting does not work correctly.

This is happening because of this line in the code:

table-core/src/features/Sorting.ts

getAutoSortingFn: () => {
        const firstRows = table.getFilteredRowModel().flatRows.slice(10)
...
}

This should have been:

 const firstRows = table.getFilteredRowModel().flatRows.slice(0, 10)

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/optimistic-shadow-3z2j6c?file=%2Fsrc%2FmakeData.ts%3A1%2C1

Steps to reproduce

Check the sorting on the Status column

Expected behavior

The Status column should be sorted correctly.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows with Chrome

react-table version

v8.9.2

TypeScript version

No response

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions