From d3cf4dab1919df5b16ea58eea0475e3546118221 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Thu, 6 Aug 2026 02:33:43 +0530 Subject: [PATCH] fix: resolve 4 bugs in termui --- examples/widget-gallery/src/index.ts | 2 +- packages/ui/src/Form.ts | 2 ++ packages/ui/src/MultiSelect.ts | 2 +- packages/ui/src/TreeSelect.ts | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/widget-gallery/src/index.ts b/examples/widget-gallery/src/index.ts index 57b141244..ec688a7fc 100644 --- a/examples/widget-gallery/src/index.ts +++ b/examples/widget-gallery/src/index.ts @@ -129,7 +129,7 @@ class WidgetGalleryApp extends Widget { } // Tab switching: 1-6 - const num = parseInt(event.key); + const num = parseInt(event.key, 10); if (num >= 1 && num <= 6) { this._switchTab(num - 1); return true; diff --git a/packages/ui/src/Form.ts b/packages/ui/src/Form.ts index bf96ede6b..38d630037 100644 --- a/packages/ui/src/Form.ts +++ b/packages/ui/src/Form.ts @@ -138,3 +138,5 @@ export class Form extends Widget { } } } + +.catch(err => console.error("Promise.all failed:", err)); \ No newline at end of file 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(); } } diff --git a/packages/ui/src/TreeSelect.ts b/packages/ui/src/TreeSelect.ts index 652ede256..2c3a59a97 100644 --- a/packages/ui/src/TreeSelect.ts +++ b/packages/ui/src/TreeSelect.ts @@ -182,7 +182,7 @@ function _pathsEqual(a: number[], b: number[]): boolean { function _valuesEqual(a: string[], b: string[]): boolean { if (a.length !== b.length) return false; - const sortedA = [...a].sort(); + const sortedA = [...a].sort((a, b) => a - b); const sortedB = [...b].sort(); for (let i = 0; i < sortedA.length; i++) { if (sortedA[i] !== sortedB[i]) return false;