💄 菜单展开数量为 0 时,popup 展开的菜单排在编辑/脚本设置之前 - #1688
Merged
Merged
Conversation
菜单展开数量设为 0 时菜单只在展开脚本后出现,但仍渲染在折叠区之外, 用户要先跳过编辑、脚本设置、删除等操作项才能点到菜单。改为该模式下 把菜单移入折叠面板并置顶,展开即可直接点菜单;>0 的常驻+截断行为不变。
Collaborator
|
本次在原 PR head
对比原 PR 的行为后确认, 本地证据(基于发布 head
PR 标题和 body 未修改。GitHub checks 在留言时仍为 pending/in progress,真实浏览器扩展视觉验证也未在本次本地流程中执行。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
N/A — 本次为主动优化,没有关联 issue。
背景
用户提出的用户体验优化
设置里「菜单展开数量」填 0 表示「展开脚本后才显示菜单」。但当时的实现只是把菜单的可见性挂到折叠面板状态上,菜单节点本身仍渲染在折叠区之外(
CollapsiblePrimitive.Content之后)。结果是展开脚本后,DOM/视觉顺序是:编辑 → 脚本设置 →(站点范围操作)→ 删除 → 菜单。用户为了点一个 GM 菜单,要先越过一整列低频操作项。本次改动
menuExpandNum === 0时,把 GM 菜单移入折叠面板内部并置于最前,展开脚本后第一眼就是菜单,「编辑 / 脚本设置 / 删除」跟在其后。menuExpandNum > 0的行为完全不变:菜单仍常驻在脚本行下方(不在折叠区内),超出数量的部分折叠并显示展开/收起按钮。用户配置项也保持原位(始终可见区域),不随本次改动移动。实现考虑
menuNodes变量,两处按menusInCollapsible择一渲染,避免同一段渲染逻辑复制两份。isActive ? allVisibleMenus : []这个手动可见性判断:RadixCollapsible.Content在关闭时本就不挂载子节点,收起时菜单自然不渲染(测试里断言了收起态查不到菜单项)。shouldTruncateMenus/isMenuExpanded)只在menuExpandNum > 0时有意义,条件里显式排除了 0 模式。建议审查重点
已知限制
仅做了单元测试层面的 DOM 顺序验证,没有跑真实浏览器扩展做视觉确认。
验证
新增两条测试(先失败后通过):
expected 10 to be less than 7)。