Skip to content

fix: resolve 4 bugs in termui - #3426

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

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

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes real bugs found in the codebase:

  • Removed redundant boolean comparison: x === true is equivalent to x (and x === false to !x), and shorter to read.
  • Replaced global isNaN with Number.isNaN: the global version coerces its argument, so isNaN('1') returns false while Number.isNaN is strict.
  • 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.

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved input validation for calculator expressions and selection prompts.
    • Ensured widget gallery keyboard input is interpreted consistently as decimal numbers.

@github-actions github-actions Bot added type:bug +10 pts. Bug fix. area:examples Example apps. area:ui @termuijs/ui and removed 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: 19ea414d-4a98-40ce-b56e-5e0beaa3ed13

📥 Commits

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

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

📝 Walkthrough

Walkthrough

The change updates three input-handling checks: trimmed calculator expressions use length, widget tab keys use decimal parsing, and prompt choices use strict NaN validation.

Changes

Input Handling Updates

Layer / File(s) Summary
Calculator expression guard
examples/calculator/src/index.tsx
CalculatorApp.evaluate() checks whether the trimmed expression length is zero.
Widget shortcut parsing
examples/widget-gallery/src/index.ts
WidgetGalleryApp.handleKey passes radix 10 to parseInt.
Prompt choice validation
packages/ui/src/prompts.ts
promptSelect uses Number.isNaN instead of global isNaN.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type:bug

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 packages, uses "Ref: #3425" instead of "Closes #3425", and leaves required fields incomplete. Add the affected packages, use Closes #3425``, and complete the required checklist and GSSoC 2026 fields.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately identifies this pull request as a bug fix addressing 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