From 573ac3318298ba31d2d19629513a3609e87531fa Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Fri, 17 Jul 2026 22:21:28 -0400 Subject: [PATCH] fix(workspace): align sort menu state with effective ordering (#6066) --- static/ui.js | 4 ++-- tests/test_issue6066_workspace_sort.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/static/ui.js b/static/ui.js index 4c87e913..cdbca24f 100644 --- a/static/ui.js +++ b/static/ui.js @@ -18841,7 +18841,7 @@ function _syncWorkspacePrefsIndicators(ind=$('workspaceHiddenIndicator'),dot=$(' } function _syncWorkspaceSortMenuState(menu=_workspacePrefsMenu){ if(!menu||!menu.querySelectorAll)return; - const active=_normalizeWorkspaceSortKey(S.workspaceSortKey); + const active=_effectiveWorkspaceSortKey(); const createdOk=_workspaceCreatedSortAvailable(); menu.querySelectorAll('.workspace-prefs-item--radio').forEach(row=>{ const input=row&&row.querySelector?row.querySelector('input[name="workspaceSortKey"]'):null; @@ -18935,7 +18935,7 @@ function _buildWorkspacePrefsMenu(){ head.textContent=groupLabel; group.appendChild(head); const createdOk=_workspaceCreatedSortAvailable(); - const active=_normalizeWorkspaceSortKey(S.workspaceSortKey); + const active=_effectiveWorkspaceSortKey(); [['name-asc','workspace_sort_name_asc'],['name-desc','workspace_sort_name_desc'],['created-desc','workspace_sort_created_desc'],['modified-desc','workspace_sort_modified_desc']].forEach(([key,i18nKey])=>{ const disabled=key==='created-desc'&&!createdOk; const row=document.createElement('label'); diff --git a/tests/test_issue6066_workspace_sort.py b/tests/test_issue6066_workspace_sort.py index de152e1b..4f02c172 100644 --- a/tests/test_issue6066_workspace_sort.py +++ b/tests/test_issue6066_workspace_sort.py @@ -219,6 +219,23 @@ if(S._workspaceBirthtimeSeen!==false||_workspaceCreatedSortAvailable()!==false|| assert result.returncode == 0, result.stderr +def test_unavailable_created_pref_uses_effective_menu_radio_state(): + result = _run_sort_harness(""" +const mkRow=value=>{ + const input={value,checked:false,disabled:false}; + return {_input:input,attrs:{},classList:{toggle(){}},setAttribute(k,v){this.attrs[k]=String(v);},querySelector(sel){return sel==='input[name="workspaceSortKey"]'?input:null;}}; +}; +const nameRow=mkRow('name-asc'); +const createdRow=mkRow('created-desc'); +_workspacePrefsMenu={querySelectorAll(sel){return sel==='.workspace-prefs-item--radio'?[nameRow,createdRow]:[];}}; +S._workspaceBirthtimeSeen=false; +S.workspaceSortKey='created-desc'; +_syncWorkspaceSortMenuState(); +if(nameRow._input.checked!==true||nameRow.attrs['aria-checked']!=='true'||createdRow._input.checked!==false||createdRow._input.disabled!==true||createdRow.attrs['aria-checked']!=='false'||createdRow.attrs['aria-disabled']!=='true')process.exit(1); +""") + assert result.returncode == 0, result.stderr + + def test_birthtime_support_scope_resets_on_workspace_change(): result = _run_sort_harness(""" const input={value:'created-desc',checked:true,disabled:false}; @@ -284,6 +301,7 @@ def test_sort_public_surface_text_shape(): "workspace_sort_created_desc", "workspace_sort_modified_desc", "workspace_sort_created_unavailable"): assert key in UI_JS or key in I18N_JS + assert UI_JS.count("const active=_effectiveWorkspaceSortKey();") >= 2 assert "row.setAttribute('aria-disabled',disabled?'true':'false');" in UI_JS assert "Number(a[field])" not in UI_JS assert I18N_JS.count("workspace_sort_by:") == I18N_JS.count("workspace_show_hidden_files:")