Skip to content

fix(apps): sort event type duration badges numerically - #29954

Open
yuvrajnode wants to merge 1 commit into
calcom:mainfrom
yuvrajnode:fix/event-type-duration-badge-sort
Open

fix(apps): sort event type duration badges numerically#29954
yuvrajnode wants to merge 1 commit into
calcom:mainfrom
yuvrajnode:fix/event-type-duration-badge-sort

Conversation

@yuvrajnode

@yuvrajnode yuvrajnode commented Aug 13, 2026

Copy link
Copy Markdown

What

Fixes duration badge ordering on the app-installation event-type picker (EventTypeCard in EventTypesStepCard.tsx).

Why

Array.prototype.sort() with no comparator coerces every element to a string before comparing. For a number array like [15, 30, 60, 90, 120], that produces lexicographic order — 120 sorts before 15 because '1' < '2' as characters. Concretely, an event type with those durations rendered its badges as:

120m 15m 30m 60m 90m

instead of the expected:

15m 30m 60m 90m 120m

Fix

Pass an explicit numeric comparator: .sort((a, b) => a - b). This matches the convention already used for sorting numbers elsewhere in the codebase (getUserAvailability.ts, slots.ts).

Testing

Verified locally that [15, 30, 60, 90, 120].sort() produces [120, 15, 30, 60, 90] and .sort((a,b) => a-b) produces [15, 30, 60, 90, 120]. No behavior change for single-duration event types.

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @yuvrajnode! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@yuvrajnode
yuvrajnode marked this pull request as ready for review August 13, 2026 07:44
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c881bf7f-df4b-43e0-88c9-f4acbb2a60a5

📥 Commits

Reviewing files that changed from the base of the PR and between 176037d and 5017c73.

📒 Files selected for processing (1)
  • apps/web/components/apps/installation/EventTypesStepCard.tsx

📝 Walkthrough

Walkthrough

The event types step card now sorts event durations by numeric value. This replaces default lexicographic sorting.

Mergeability Score: ⚪ Minimal · up to 5017c

This change corrects duration badge ordering without altering single-duration behavior or introducing broader product impact. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the numeric sorting fix for event type duration badges.
Description check ✅ Passed The description explains the sorting issue, the numeric comparator fix, the affected picker, and the testing performed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant