mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-10-23 14:32:36 +00:00
fix: Observer Neighbors tool header never actually got the sort-active highlight class
Caught live on stg: clicking a column sorted correctly (confirmed via sortValue/data ordering) but no header ever visually highlighted as the active sort column -- the thead template hardcoded class="sortable" on every <th> and never added sort-active, even though sortArrow() computed the right up/down glyph. Refactored into a sortTh(col, label) helper so the class and arrow can't drift apart again; added a regression test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a4400cc19e
commit
aeb441540d
2 files changed
+19
-5
No files matched your search
@@ -83,6 +83,11 @@
|
||||
return '<span class="sort-arrow">' + (sortState.dir === 'asc' ? '↑' : '↓') + '</span>';
|
||||
}
|
||||
|
||||
function sortTh(col, label) {
|
||||
var cls = 'sortable' + (col === sortState.col ? ' sort-active' : '');
|
||||
return '<th class="' + cls + '" data-sort-col="' + col + '">' + label + sortArrow(col) + '</th>';
|
||||
}
|
||||
|
||||
function matchesFilter(row) {
|
||||
if (!filterText) return true;
|
||||
var observer = (row.observerName || row.observerId || '').toLowerCase();
|
||||
@@ -149,12 +154,12 @@
|
||||
|
||||
wrap.innerHTML =
|
||||
'<table class="data-table" id="obs-nb-table"><thead><tr>' +
|
||||
'<th class="sortable" data-sort-col="observer">Observer' + sortArrow('observer') + '</th>' +
|
||||
'<th class="sortable" data-sort-col="neighbor">Neighbor' + sortArrow('neighbor') + '</th>' +
|
||||
sortTh('observer', 'Observer') +
|
||||
sortTh('neighbor', 'Neighbor') +
|
||||
'<th>Configured Scope</th>' +
|
||||
'<th class="sortable" data-sort-col="evidence">Packet Evidence' + sortArrow('evidence') + '</th>' +
|
||||
'<th class="sortable" data-sort-col="status">Status' + sortArrow('status') + '</th>' +
|
||||
'<th class="sortable" data-sort-col="reportedAt">Reported' + sortArrow('reportedAt') + '</th>' +
|
||||
sortTh('evidence', 'Packet Evidence') +
|
||||
sortTh('status', 'Status') +
|
||||
sortTh('reportedAt', 'Reported') +
|
||||
'</tr></thead><tbody>' + rows + '</tbody></table>';
|
||||
|
||||
var table = document.getElementById('obs-nb-table');
|
||||
|
||||
@@ -151,6 +151,15 @@ function waitForLoad() {
|
||||
assert.strictEqual(sv({ neighborPubkey: 'AABB' }, 'neighbor'), 'aabb');
|
||||
});
|
||||
|
||||
await test('the default-sorted column (Observer) header carries sort-active', async () => {
|
||||
const sb = initWith([makeRow(), makeRow({ observerId: 'obs2', observerName: 'Observer Two' })]);
|
||||
await waitForLoad();
|
||||
const wrap = sb.__docStore['obs-nb-table-wrap'];
|
||||
assert.ok(/data-sort-col="observer"[^>]*class="sortable sort-active"|class="sortable sort-active"[^>]*data-sort-col="observer"/.test(wrap.innerHTML),
|
||||
`expected Observer header to carry sort-active by default; got: ${wrap.innerHTML.slice(0, 400)}`);
|
||||
assert.ok(!/data-sort-col="neighbor"[^>]*sort-active/.test(wrap.innerHTML), 'Neighbor header should not be marked active');
|
||||
});
|
||||
|
||||
await test('sortValue: evidence sorts booleans as 1/0', () => {
|
||||
const sb = createSandbox([]);
|
||||
const sv = sb.window.ObserverNeighborsTool.sortValue;
|
||||
|
||||
Reference in new issue
Block a user