fix(ui): align sidebar pin controls

Keep the pin with the expanded header actions and center the collapsed version link with the navigation rail.
This commit is contained in:
PathGao
2026-07-30 14:46:43 +08:00
parent 5373786faa
commit b2fe233108
3 changed files with 36 additions and 31 deletions
+9 -3
View File
@@ -21,14 +21,20 @@ function renderSidebar() {
);
}
test('keeps the sidebar expanded after pinning it and restores the choice', () => {
test('keeps the sidebar expanded after pinning it from the header and restores the choice', () => {
const first = renderSidebar();
const sidebar = first.container.querySelector('.ant-layout-sider');
const sidebarRoot = first.container.querySelector('.ant-sidebar');
expect(sidebar?.classList.contains('ant-layout-sider-collapsed')).toBe(true);
fireEvent.click(screen.getByRole('button', { name: 'Pin sidebar' }));
fireEvent.mouseLeave(first.container.querySelector('.ant-sidebar')!);
fireEvent.mouseEnter(sidebarRoot!);
const pinButton = screen.getByRole('button', { name: 'Pin sidebar' });
expect(pinButton.closest('.brand-actions')).not.toBeNull();
fireEvent.click(pinButton);
fireEvent.mouseLeave(sidebarRoot!);
expect(sidebar?.classList.contains('ant-layout-sider-collapsed')).toBe(false);
expect(localStorage.getItem('sidebar-pinned')).toBe('true');