fix: sort milestones ascending by ID in browser UI#644
Open
raincrossgazette wants to merge 1 commit into
Open
Conversation
Previously the milestones page sorted milestone cards by ID descending (newest first), so a project with phases m-3 through m-6 would display Phase 9 (m-6) at the top, followed by Phase 7 (m-4) and Phase 8 (m-5). This reverses the sort to ascending so milestones appear in their natural creation order (m-1 → m-2 → m-3 … ), matching the sequence users intend when they create milestones in phase/sprint order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The milestones page in the browser UI sorts milestone cards by ID descending (newest first). This means a project with milestones created in phase order ends up displaying them in reverse — e.g. Phase 9 (m-6) appears at the top, then Phase 7 (m-4), then Phase 8 (m-5).
The comment in the code itself acknowledges the intent: "IDs are sequential m-0, m-1, etc." — but descending order defeats the natural sequence users build when creating milestones in phase/sprint order.
Root cause
In
src/web/components/MilestonesPage.tsx, thesortByIdDesccomparator returnsbNum - aNum, sorting largest ID first:Fix
Flip the comparator to ascending (
aNum - bNum) so milestones display in creation order (m-1 → m-2 → m-3 …). Also renamed the function tosortByIdAscand updated comments for clarity.The fallback value for non-
m-Nmilestones was also changed from-1toNumber.MAX_SAFE_INTEGERso that milestones without a numeric ID sort to the end rather than colliding at the front.Behavior change
This matches what users expect when they name milestones in phase/sprint sequence.
Testing
The change is a single-line logic inversion in the comparator function. No new test assertions exist for this display order in the existing test suite (
web-milestones-page-search.test.tsx,web-milestones-page-unassigned-filter.test.tsx).