Fix table sort does not work if table has formula column #1528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Sort does not work if table has formula column.
Example: in this table setup, the right-most column is a formula column. The table sort is set to num descending, however the table UI displays rows order incorrectly.
Cause
In a commit related to formula field, it sets all rows to
rowsLocal
if there is formula column in the table.rowy/src/atoms/tableScope/rowActions.ts
Lines 389 to 391 in 2715a80
rowsLocal
is designed to hold our of order rows that are supposed to be a very small set, and they are always displayed at the top of the table UI. They are not sorted or ordered.rowy/src/atoms/tableScope/table.ts
Lines 170 to 197 in 0099bd1
However, the commit would set all rows to rowsLocal, as a result, rows are displayed without going through filters or sorts.
Fix
Simply remove the condition for local row would fix this issue.
After fix:
![Screenshot 2024-01-23 at 07 25 17](https://private-user-images.githubusercontent.com/34177142/298760658-21984ebe-f736-4b19-82ce-aac8f9a9c28e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA3NDY0MDUsIm5iZiI6MTcyMDc0NjEwNSwicGF0aCI6Ii8zNDE3NzE0Mi8yOTg3NjA2NTgtMjE5ODRlYmUtZjczNi00YjE5LTgyY2UtYWFjOGY5YTljMjhlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzEyVDAxMDE0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ1ZDI1OWZjNzk5ODI3MzExNWQ0MWU4MWExZGU2OWU3YzcxZDYzYzQ2MDY1ZGM0ODZkOWUxZDIyNzQ4MGFlYjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.CIIOaukdZ6hqwDEJekGUHTUD6PZRtKGyrHi9v99pt6c)