From 01f27d0e04258e7cbc61865873765cb41c163b2a Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Tue, 4 Aug 2026 11:34:59 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/forms-and-validation/src/index.tsx | 2 +- examples/showcase/src/index.tsx | 2 +- examples/todo-app/src/index.ts | 2 +- packages/ui/src/MultiSelect.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/forms-and-validation/src/index.tsx b/examples/forms-and-validation/src/index.tsx index e8a9bb4ea..4ac42a672 100644 --- a/examples/forms-and-validation/src/index.tsx +++ b/examples/forms-and-validation/src/index.tsx @@ -122,7 +122,7 @@ class FormsExampleApp extends Widget { return false; // Quit } - if (event.key === 'c' && event.ctrl === false) { + if (event.key === 'c' && event.ctrl !) { this.modal.show(); return true; } diff --git a/examples/showcase/src/index.tsx b/examples/showcase/src/index.tsx index 444be6698..47a52a3e3 100644 --- a/examples/showcase/src/index.tsx +++ b/examples/showcase/src/index.tsx @@ -128,7 +128,7 @@ class ShowcaseApp extends Widget { if (event.key === 'q' || (event.ctrl && event.key === 'c')) return false; // Tab switching: 1-5 - const num = parseInt(event.key); + const num = parseInt(event.key, 10); if (num >= 1 && num <= 5) { this.switchTab(num - 1); return true; diff --git a/examples/todo-app/src/index.ts b/examples/todo-app/src/index.ts index d26035d3c..d4cf9b550 100644 --- a/examples/todo-app/src/index.ts +++ b/examples/todo-app/src/index.ts @@ -104,7 +104,7 @@ class CustomMultiProgress extends (MultiProgressClass as any) { const value = Math.max(0, Math.min(1, item.value)); const filled = Math.round(barWidth * value); - const pct = Math.round(value * 100); + const pct = Math.round(value * 100 + Number.EPSILON); const percentStr = ` ${pct}% `; const showPct = barWidth >= percentStr.length; const labelStart = showPct ? Math.floor((barWidth - percentStr.length) / 2) : -1; diff --git a/packages/ui/src/MultiSelect.ts b/packages/ui/src/MultiSelect.ts index b4116418f..327e1eee2 100644 --- a/packages/ui/src/MultiSelect.ts +++ b/packages/ui/src/MultiSelect.ts @@ -30,7 +30,7 @@ export class MultiSelect extends Widget { } get selectedOptions(): MultiSelectOption[] { - return [...this._checked].sort().map(i => this._options[i]); + return [...this._checked].sort((a, b) => a - b).map(i => this._options[i]); } selectNext(): void { if (this._options.length === 0) return; let n = this._cursorIndex + 1; while (n < this._options.length && this._options[n].disabled) n++; if (n < this._options.length) { this._cursorIndex = n; this.markDirty(); } } selectPrev(): void { if (this._options.length === 0) return; let n = this._cursorIndex - 1; while (n >= 0 && this._options[n].disabled) n--; if (n >= 0) { this._cursorIndex = n; this.markDirty(); } }