luci-base: form: fix sort order bug triggered by integer types
authorPaul Donald <newtwen+github@gmail.com>
Mon, 25 Nov 2024 20:32:39 +0000 (21:32 +0100)
committerPaul Donald <newtwen+github@gmail.com>
Mon, 25 Nov 2024 20:32:39 +0000 (21:32 +0100)
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
modules/luci-base/htdocs/luci-static/resources/form.js

index 53ea3c5bcd9176a15f2a97c98897a7262d7c4a06..7cf2ae75971ca7cf7c56ae8101f9f8f20632537f 100644 (file)
@@ -3068,8 +3068,10 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p
                                n.classList.remove('flash')
                        });
 
+                       val = Array.isArray(val) ? val.join(' '): val;
+                       val = `${val}`; // coerce non-string types to string
                        list.push([
-                               ui.Table.prototype.deriveSortKey((val != null) ? val.trim() : ''),
+                               ui.Table.prototype.deriveSortKey((val != null && typeof val.trim === 'function') ? val.trim() : ''),
                                tr
                        ]);
                }, this));