Skip to content

fix(tasks): apply ID sorting on the first click - #483

Open
WiseShrestha wants to merge 1 commit into
CCExtractor:mainfrom
WiseShrestha:gsoc/ccsync-id-sort-first-click
Open

WiseShrestha wants to merge 1 commit into
CCExtractor:mainfrom
WiseShrestha:gsoc/ccsync-id-sort-first-click

Conversation

@WiseShrestha

Copy link
Copy Markdown

Description

Keep the stored ID sort direction aligned with the descending order applied on initial load and sync. The first ID click now sorts ascending in both cases.

Related to #433 and #476.

Verification

  • All 753 frontend tests passed and the production build succeeded.
  • Chromium reproduced and verified the fix with Taskwarrior-exported sample tasks and real IndexedDB. The sync HTTP response was simulated.

AI Usage Disclosure

  • AI-generated. Codex investigated the bug, wrote the patch and regression tests, ran the verification, and drafted the commit message and PR description.

@github-actions

Copy link
Copy Markdown

Thank you for opening this PR!

Before a maintainer takes a look, it would be really helpful if you could walk through your changes using GitHub's review tools.

Please take a moment to:

  • Check the "Files changed" tab
  • Leave comments on any lines for functions, comments, etc. that are important, non-obvious, or may need attention
  • Clarify decisions you made or areas you might be unsure about and/or any future updates being considered.
  • Finally, submit all the comments!

More information on how to conduct a self review:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/reviewing-proposed-changes-in-a-pull-request

This helps make the review process smoother and gives us a clearer understanding of your thought process.

Once you've added your self-review, we'll continue from our side. Thank you!

const sortedTasks = sortTasksById(updatedTasks, DEFAULT_ID_SORT_ORDER);
setTasks(sortedTasks);
setTempTasks(sortedTasks);
setIdSortOrder(DEFAULT_ID_SORT_ORDER);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sync reloads the rows in descending ID order. If I had sorted ascending before syncing, the stored direction would still be asc so the next click would apply descending order again and look like it did nothing. Resetting the direction here keeps it aligned with the rows on screen.

});

fireEvent.click(idHeader);
expect(visibleTaskIds()).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The test sorts ascending before syncing so it exercises the stale-state case. It then checks the visible row order after sync and after one click. That catches the extra-click bug, which a test that only checks whether the rows eventually change would miss.

@WiseShrestha WiseShrestha left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I left inline comments explaining why sync resets the stored ID sort direction and how the regression test verifies that the first click after sync sorts ascending.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant