Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions e2e/ui/03-workbench-settings.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ test('desktop settings navigation reopens on the current page', async ({ page })
await collapse.click();
await expect(page.locator('#settingsSidebar')).toHaveAttribute('aria-hidden', 'true');
await expect(expand).toBeFocused();
await expand.evaluate(button => {
delete button.dataset.focusAfterClick;
button.addEventListener('click', () => {
button.dataset.focusAfterClick = document.activeElement?.id || '';
}, { once: true });
});
await expand.press('Enter');
const focusAfterClick = await page.locator('#settingsSidebarExpand').getAttribute('data-focus-after-click');
expect(focusAfterClick).toBe('settingsSidebarToggle');
await expect(collapse).toBeVisible();
await expect(collapse).toBeFocused();
await expect(page).toHaveURL(/#\/settings$/);
Expand Down
17 changes: 11 additions & 6 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1018,17 +1018,17 @@ function bind(){
$('#settingsSidebarToggle')?.addEventListener('click',()=>{cancelSettingsRouteTransition();setSettingsSidebarExpanded(!settingsSidebarExpanded())});
$('#settingsSidebarExpand')?.addEventListener('click',()=>{
cancelSettingsRouteTransition();
setSettingsSidebarExpanded(true);
// Wait for the sidebar's descendants to inherit the restored visibility; reduced
// motion still runs a near-zero visibility transition, so retry for a few frames.
setSettingsSidebarExpanded(true,document.activeElement===document.body);
// Focus normally moves before the opener hides. If the toggle cannot take
// focus yet, focus falls back to the body; retry for a few frames.
let frames=0;
const focusToggle=()=>requestAnimationFrame(()=>{
if(!settingsSidebarExpanded()||document.activeElement!==document.body)return;
const toggle=$('#settingsSidebarToggle');
toggle?.focus({preventScroll:true});
if(toggle&&document.activeElement!==toggle&&++frames<30)focusToggle();
});
requestAnimationFrame(focusToggle);
if(document.activeElement!==$('#settingsSidebarToggle'))focusToggle();
});
document.addEventListener('click',event=>{
if(document.body.classList.contains('management-mode')&&event.target instanceof Element&&event.target.closest('.collab-rail-toggle')){
Expand Down Expand Up @@ -1775,7 +1775,7 @@ settingsRouteMotion.addEventListener('change',()=>{
if(pending)switchView(pending);
setSettingsSidebarExpanded(settingsSidebarExpanded());
});
function setSettingsSidebarExpanded(expanded){
function setSettingsSidebarExpanded(expanded,focusToggle=false){
const managing=document.body.classList.contains('management-mode');
const open=managing&&expanded;
const entering=managing&&!settingsSidebarWasManaged;
Expand All @@ -1802,7 +1802,7 @@ function setSettingsSidebarExpanded(expanded){
toggle.title=open?'收起设置导航':'展开设置导航';
}
const reopen=$('#settingsSidebarExpand');
if(reopen)reopen.hidden=!managing||open;
if(reopen&&!open)reopen.hidden=!managing;
const mobileToggle=$('.collab-rail-toggle');
if(mobileToggle){
mobileToggle.setAttribute('aria-expanded',String(open));
Expand All @@ -1819,6 +1819,11 @@ function setSettingsSidebarExpanded(expanded){
if(managing&&!open)sidebar.setAttribute('aria-hidden','true');
else sidebar.removeAttribute('aria-hidden');
}
if(reopen&&open){
// Transfer focus before hiding the expand button.
if(focusToggle||document.activeElement===reopen)toggle?.focus({preventScroll:true});
reopen.hidden=true;
}
if(animateEntry){
// Keep the mounted panel at its closed geometry for one layout before reveal.
settingsSidebarEntryFrame=requestAnimationFrame(()=>{
Expand Down
7 changes: 1 addition & 6 deletions web/app/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@ body.management-mode .platform-sidebar {
width: var(--sidebar-w) !important;
clip-path: inset(0 0 0 0 round 16px);
opacity: 1;
visibility: visible;
transition:
clip-path var(--settings-sidebar-duration) var(--settings-sidebar-ease),
visibility 0s;
transition: clip-path var(--settings-sidebar-duration) var(--settings-sidebar-ease);
}

body.management-mode .shell-main {
Expand All @@ -273,9 +270,7 @@ body.management-mode .app-shell::before {

body.management-mode:is(.settings-sidebar-hidden, .settings-sidebar-entering) .platform-sidebar {
clip-path: inset(0 100% 0 0 round 16px);
visibility: hidden;
pointer-events: none;
transition-delay: 0s, var(--settings-sidebar-duration);
}

@media (prefers-reduced-motion: reduce) {
Expand Down
Loading