Skip to content

fix: resolve 4 bugs in termui - #3516

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

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

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Added explicit radix to parseInt: without 10, strings like '0x1F' or '08' parse in unintended bases.
  • Simplified empty-string validation: comparing trim() to '' misses whitespace-only input; .trim().length === 0 is explicit.
  • Replaced global isNaN with Number.isNaN: the global version coerces its argument, so isNaN('1') returns false while Number.isNaN is strict.
  • Fixed default sort: .sort() coerces elements to strings, so [10, 9, 2] sorts as [10, 2, 9]; numeric comparator sorts correctly.

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: #3515

Summary by CodeRabbit

  • Bug Fixes
    • Improved negative-number validation in the calculator.
    • Fixed tab-key handling in the widget gallery for consistent tab switching.
    • Corrected multi-select option ordering when selections include multiple-digit indices.

@github-actions github-actions Bot added the type:bug +10 pts. Bug fix. label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 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: 8103e784-b90f-4b3c-8672-98e1d099511d

📥 Commits

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

📒 Files selected for processing (3)
  • examples/calculator/src/index.tsx
  • examples/widget-gallery/src/index.ts
  • packages/ui/src/MultiSelect.ts

📝 Walkthrough

Walkthrough

The changes make numeric validation, parsing, and sorting explicit in the calculator example, widget gallery, and multi-select component.

Changes

Numeric handling corrections

Layer / File(s) Summary
Calculator negative-number validation
examples/calculator/src/index.tsx
safeEval now uses Number.isNaN(Number(tokens[1])).
Widget gallery key parsing
examples/widget-gallery/src/index.ts
WidgetGalleryApp.handleKey now calls parseInt with radix 10.
Multi-select option ordering
packages/ui/src/MultiSelect.ts
selectedOptions now sorts checked indices numerically before mapping them to options.

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

Possibly related PRs

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fixes and testing, but it omits the required package section and uses “Ref: #3515” instead of “Closes #”. Add the affected package names, change the issue reference to “Closes #3515”, and complete the required template sections and checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the pull request as a bug fix for four TermUI bugs.
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.

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

Labels

area:examples Example apps. 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