From d70dd1a3ce4cec1f78ef1fea8ae23f52821612aa Mon Sep 17 00:00:00 2001 From: LegGasai Date: Wed, 18 Nov 2026 13:50:08 +0800 Subject: [PATCH] fix(ui-sidebar): rest panel trailing content at the row's end and swap it for the unpin action on hover A panel row laid its trailing content, such as a count, before the 38px it keeps for the unpin action, so the content sat away from the row's end with an empty gap after it. Where the pointer hovers, the unpin action shows only on hover or keyboard focus, so the content now rests in the action's place and gives way to it, as a Session row's time gives way to its actions. On a touch device the action always shows and the content stays before it. --- packages/client/ui-sidebar/README.i18n.yaml | 4 ++-- packages/client/ui-sidebar/README.md | 2 +- packages/client/ui-sidebar/README.zh.md | 2 +- .../ui-sidebar/src/client/SidebarRoot.module.css | 16 ++++++++++++++-- .../tests/sidebar-styles.client.spec.ts | 16 ++++++++++++++++ 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/client/ui-sidebar/README.i18n.yaml b/packages/client/ui-sidebar/README.i18n.yaml index 0713c88064..7d7a31ef1a 100644 --- a/packages/client/ui-sidebar/README.i18n.yaml +++ b/packages/client/ui-sidebar/README.i18n.yaml @@ -21,8 +21,8 @@ en: 6bc49e22f0f73f07 zh: 10883997ccb7d145 /deepseek-ai-dsh-client-ui-sidebar/use-this-package/global-panel-entries: - en: e7cfc9a3d175045d - zh: 2bf0d5d6d0c64de8 + en: c0434112ae12b04a + zh: 20da5afa27de5177 /deepseek-ai-dsh-client-ui-sidebar/use-this-package/collapse-behavior: en: 61d563b0f82ff658 zh: f27504350dd14d4c diff --git a/packages/client/ui-sidebar/README.md b/packages/client/ui-sidebar/README.md index 0328dd05fa..76cfeb907c 100644 --- a/packages/client/ui-sidebar/README.md +++ b/packages/client/ui-sidebar/README.md @@ -41,7 +41,7 @@ The expanded brand row renders `sidebar.brand.mark` and `sidebar.brand.name` as Plugins add an icon component to the root-scoped `sidebar.panellist` list with an `id`, optional `order`, and a string or locale-aware `label`. The same id addresses the component registered in the layout's root-scoped `main` keyed slot; selecting a missing main entry throws without changing the current selection. The label supplies plain visible text, the accessible name, and the collapsed tooltip. Expanded navigation rows are 32px high with a 2px gap; collapsed rail controls remain 36px high with a 12px gap. Expanded navigation keeps an 8px bottom margin before the Workspace header. Each row reads its own selected state through `usePanelInfo`; moving DOM focus to search or a directory picker does not change the displayed panel or its selected row. With no panel registrations, neither the list nor spacing for it is rendered. The shipped composition registers no example panel. -A panel may also register non-interactive inline content in the root-scoped `sidebar.panellist.trailing` list with the same `id`, such as a count. It receives `wide` and `active`. The expanded row lays it out after the title and before the space the unpin action takes, as a Session row lays out its trailing icons, so a row without content keeps its full title width and the unpin action shows beside the content. The collapsed rail shows it over the icon's top trailing corner. It renders inside the row button, so it holds no interactive elements; its text becomes the button's accessible description, so decorative parts must be `aria-hidden`. +A panel may also register non-interactive inline content in the root-scoped `sidebar.panellist.trailing` list with the same `id`, such as a count. It receives `wide` and `active`. The expanded row lays it out after the title, so a row without content keeps its full title width. Where the pointer hovers, the content rests at the row's end, in the place of the unpin action, and gives way to that action while the row is hovered or holds keyboard focus, as a Session row's time gives way to its actions; on a touch device, where the unpin action always shows, the content stays before it. The collapsed rail shows it over the icon's top trailing corner. It renders inside the row button, so it holds no interactive elements; its text becomes the button's accessible description, so decorative parts must be `aria-hidden`. While the root-scoped `sidebar.panellist.actions` list has registrations, a **More** button styled as a panel row follows the rows inside the navigation landmark; the collapsed rail shows its label as a tooltip. It opens a menu whose rows are that list's registrations. Each receives `entries` (customizable panels in registration order with `id`, `label`, `pinned`, and `active`; Plugins is never listed), `onOpen(id)`, which selects the panel, `onPinnedChange(id, pinned)`, and `onDismiss()`, which closes the menu. The sidebar keeps one in-memory list of unpinned panel ids shared by every Session; Plugins always shows. While More shows, expanded rows other than Plugins show an unpin action on hover or keyboard focus; devices without hover show it continuously. Its resting color matches the Session pin marker, and its tooltip says “Unpin from left sidebar”. Both sidebar and More entries follow the same registration order rather than pin timing. The default More menu lists only unpinned panels before plugin browsing and creation; opening a panel does not pin it, while its separate pin icon returns the row to the sidebar and dismisses the menu. Choices reset when the plugin reloads and legacy localStorage values are ignored. Unpinning hides only the row, and only while More shows; without `sidebar.panellist.actions` registrations every registered row shows again. The main panel, its registration, and the current selection stay unchanged. Unregistered panel ids remain in the in-memory list until the plugin reloads. diff --git a/packages/client/ui-sidebar/README.zh.md b/packages/client/ui-sidebar/README.zh.md index e68792963e..0d76837aca 100644 --- a/packages/client/ui-sidebar/README.zh.md +++ b/packages/client/ui-sidebar/README.zh.md @@ -41,7 +41,7 @@ dsh Web 客户端的侧边栏让用户识别当前构建、启动新会话、将 插件在 root 作用域的 `sidebar.panellist` list 中注册图标组件,提供 `id`、可选 `order`,以及字符串或 locale-aware 的 `label`。同一个 id 寻址布局中 root 作用域 `main` keyed slot 的组件;选择不存在的主面板条目会抛错,并保留当前选中态。标签提供普通可见文字、无障碍名称和折叠提示。展开态导航行高 32px,间距为 2px;折叠窄栏控件保持 36px 高和 12px 间距。展开态导航区域与工作区标题行之间保留 8px 底部外边距。每一行通过 `usePanelInfo` 读取自己的选中态;DOM 焦点移到搜索框或目录选择器时,显示的面板及其列表项选中态不变。没有面板注册项时,列表及其间距均不渲染。产品随附的组合不注册示例面板。 -面板还可以用相同 `id` 在 root 作用域的 `sidebar.panellist.trailing` list 中注册不可交互的行内内容,例如数量。它接收 `wide` 与 `active`。展开的行把它排在标题之后、取消固定操作所占空间之前,与会话行排布行尾图标的方式相同:没有内容的行保留完整的标题宽度,取消固定操作显示在内容旁边。收起的窄栏在图标右上角显示它。它渲染在行按钮内,因此不能包含可交互元素;它的文字成为按钮的无障碍描述,因此装饰性的部分必须设为 `aria-hidden`。 +面板还可以用相同 `id` 在 root 作用域的 `sidebar.panellist.trailing` list 中注册不可交互的行内内容,例如数量。它接收 `wide` 与 `active`。展开的行把它排在标题之后,没有内容的行保留完整的标题宽度。在支持悬停的设备上,内容停在行尾、取消固定操作所在的位置,行被悬停或获得键盘焦点时让位给该操作,与会话行的时间让位给行内操作的方式相同;在触屏设备上取消固定操作始终显示,内容留在它之前。收起的窄栏在图标右上角显示它。它渲染在行按钮内,因此不能包含可交互元素;它的文字成为按钮的无障碍描述,因此装饰性的部分必须设为 `aria-hidden`。 root 作用域的 `sidebar.panellist.actions` list 有注册项时,导航区域的面板行之后显示面板行样式的**更多**按钮;收起的窄栏以提示框显示其名称。它打开的菜单以该 list 的注册项为菜单行。每个注册项接收 `entries`(按注册顺序的可自定义面板,含 `id`、`label`、`pinned` 与 `active`;不含插件管理)、选中面板的 `onOpen(id)`、`onPinnedChange(id, pinned)`,以及关闭菜单的 `onDismiss()`。侧边栏在内存中保存所有会话共用的已收起面板 id 列表;插件管理入口始终显示。更多按钮显示时,展开态中除插件管理外的面板行在悬停或键盘聚焦时显示取消固定操作;不支持悬停的设备始终显示该操作。图标默认颜色与会话置顶标记一致,提示为“从左侧栏取消固定”。侧栏和更多菜单入口遵循相同的注册排序,不按固定时间重排。默认更多菜单在插件浏览和创建之前仅列出未固定的面板;打开面板不会将其固定,独立的固定图标则将该行放回侧边栏并关闭菜单。插件重新加载时选择重置,不读取旧 localStorage 值。收起只隐藏导航行,且仅在更多按钮显示时生效;`sidebar.panellist.actions` 没有注册项时,所有已注册的面板行重新显示。主面板、其注册和当前选中态不变。未注册面板的 id 保留在内存列表中,直到插件重新加载。 diff --git a/packages/client/ui-sidebar/src/client/SidebarRoot.module.css b/packages/client/ui-sidebar/src/client/SidebarRoot.module.css index 023dd4a0c6..61ffc2b547 100644 --- a/packages/client/ui-sidebar/src/client/SidebarRoot.module.css +++ b/packages/client/ui-sidebar/src/client/SidebarRoot.module.css @@ -693,8 +693,9 @@ outline-offset: -2px; } -/* A panel's trailing content follows the title in the row's flow, as a Session row's trailing icons do: a row without - content keeps its full title width, and the title yields room only to content that shows. On the collapsed rail it +/* A panel's trailing content follows the title in the row's flow: a row without content keeps its full title width, + and the title yields room only to content that shows. Where the pointer hovers, the content rests at the row's end + and gives way to the unpin action; elsewhere it stays before the action, which always shows. On the collapsed rail it sits over the icon's top trailing corner. */ .panelTrailing { flex: none; @@ -720,6 +721,17 @@ .panelUnpin:hover { color: var(--dsw-alias-label-primary); } .panelEntry:hover .panelUnpin, .panelEntry:has(:focus-visible) .panelUnpin { opacity: 1; } + + /* The unpin action shows only while its row is hovered or holds keyboard focus, so trailing content rests in the + action's place, as a Session row's time rests in the place of its actions: its trailing edge is the unpin glyph's, + 7px from the row's, and its box fills the rest of the 38px the row keeps for the action. */ + .panelEntryWide .panelRow { padding-right: 7px; } + .panelEntryWide .panelTrailing { + justify-content: flex-end; + min-width: 31px; + } + .panelEntry:has(.panelUnpin):hover .panelTrailing, + .panelEntry:has(.panelUnpin):has(:focus-visible) .panelTrailing { opacity: 0; } } .panelList { diff --git a/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts b/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts index 789c7cd550..51cc466da6 100644 --- a/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts +++ b/packages/client/ui-sidebar/tests/sidebar-styles.client.spec.ts @@ -205,6 +205,22 @@ describe('SidebarRoot.module.css', () => { expect(css).not.toMatch(/\.panelRow\s*\{[^}]*padding-right:\s*72px/) }) + it('rests panel trailing content in the unpin action\'s place where the pointer hovers, and swaps the two on hover or keyboard focus', () => { + const withoutComments = css.replace(/\/\*[\s\S]*?\*\//g, ' ') + // The block that also reveals the unpin action on hover. + const hover = /@media \(hover: hover\) \{((?:[^{}]*\{[^{}]*\})*[^{}]*\.panelUnpin \{ opacity: 0; \}(?:[^{}]*\{[^{}]*\})*)\s*\}/.exec(withoutComments)?.[1] ?? '' + const rule = (selector: string): string => new RegExp(`${selector.replace(/[.()[\]:]/g, '\\$&')}\\s*\\{([^{}]*)\\}`).exec(hover)?.[1]?.replace(/\s+/g, ' ').trim() ?? '' + // 7px to the unpin glyph's trailing edge and 31px of content box fill the 38px a row keeps for the action elsewhere. + expect(rule('.panelEntryWide .panelRow')).toBe('padding-right: 7px;') + expect(rule('.panelEntryWide .panelTrailing')).toBe('justify-content: flex-end; min-width: 31px;') + // Only a row that has the action hides its content, on hover and on keyboard focus alike. + expect(hover.replace(/\s+/g, ' ')).toContain( + '.panelEntry:has(.panelUnpin):hover .panelTrailing, .panelEntry:has(.panelUnpin):has(:focus-visible) .panelTrailing { opacity: 0; }', + ) + // Outside that block, where the action always shows, the content stays before the 38px. + expect(withoutComments.replace(hover, '')).not.toMatch(/\.panelTrailing[^{}]*\{[^{}]*(?:opacity|min-width)/) + }) + it('pins panel trailing content over the collapsed rail icon\'s top trailing corner', () => { const collapsed = declarations('.collapsed .panelTrailing') expect(collapsed?.get('position')).toBe('absolute')