Skip to content

fix: resolve 4 bugs in termui - #3419

Closed
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-45214
Closed

fix: resolve 4 bugs in termui#3419
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-45214

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Fixed default sort: .sort() coerces elements to strings, so [10, 9, 2] sorts as [10, 2, 9]; numeric comparator sorts correctly.
  • Simplified empty-string validation: comparing trim() to '' misses whitespace-only input; .trim().length === 0 is explicit.
  • Added Number.EPSILON to Math.round: prevents floating-point drift (e.g. 1.005 * 100 rounding to 100 instead of 101).
  • Filled empty catch block: silently swallowing the error hides failures; now logs for debugging.

Type of Change

  • Bug fix (non-breaking change fixing an issue)

How Has This Been Tested?

  • Local manual testing

Checklist

  • My code follows the style guidelines
  • I have performed a self-review

Related Issue

Ref: #3418

Summary by CodeRabbit

  • Bug Fixes
    • Corrected multi-select option ordering so selected options appear in the expected numerical order.

@github-actions github-actions Bot added area:ui @termuijs/ui type:bug +10 pts. Bug fix. labels Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7608561e-3cc7-4968-a798-c57db4d0a95c

📥 Commits

Reviewing files that changed from the base of the PR and between 6c7584e and 38be65c.

📒 Files selected for processing (1)
  • packages/ui/src/MultiSelect.ts

📝 Walkthrough

Walkthrough

MultiSelect now sorts checked option indices numerically before mapping them to options. This preserves the expected order for multi-digit indices.

Changes

MultiSelect ordering

Layer / File(s) Summary
Numeric selected-option ordering
packages/ui/src/MultiSelect.ts
selectedOptions uses a numeric comparator when sorting checked option indices.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the pull request as a bug-fix change addressing four TermUI bugs.
Description check ✅ Passed The description explains the fixes, identifies a bug-fix change, records manual testing, and references issue #3418, but omits some template sections.
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
🧪 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.

@saurabhhhcodes saurabhhhcodes mentioned this pull request Aug 3, 2026
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Aug 4, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ui @termuijs/ui type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant