This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(data-table): 行「更多操作」触发器改为数「真正会渲染的项」,空则不渲染 - #3756
Merged
Merged
Conversation
…ot handlers The row "..." (overflow) trigger was guarded on whether row-action HANDLERS were supplied (`onRowEdit` / `onRowDelete` / `rowActionDefs`), while the menu's items were filtered a second time - per item, per record - against `rowEditPredicates` / `rowDeletePredicates` and a custom action's `visible`. A row whose every item was predicate-suppressed therefore kept a trigger that opened an empty menu, which reads as a broken page (objectui#3562). The trigger is now decided by the items that will actually render for that row, and the decision is per ROW because the predicates are per record: within one table a row that keeps an action keeps its trigger while a row with nothing left renders none. The guard and the item components read the SAME visibility rule (`isBuiltinRowActionVisible` / `isCustomRowActionVisible`), so the trigger and its contents cannot drift apart; menu separators now follow the surviving groups instead of the declared ones. The actions cell itself is unchanged, so the column stays aligned with its header on tables where only some rows keep a trigger. Refs objectui#3562 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This was referenced Aug 8, 2026
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
marked this pull request as ready for review
August 8, 2026 12:08
This was referenced Aug 8, 2026
akarma-synetal
pushed a commit
to akarma-synetal/objectui
that referenced
this pull request
Aug 10, 2026
…渲染 (objectstack-ai#3758) (objectstack-ai#3816) 自定义行动作的可见性**门**用真值判断,于是 `visible: false` —— 作者能写出的 最明确的「永不显示」—— 落进「未声明门」分支,动作对所有行渲染。两处门(收敛后 各一处 `isCustomRowActionVisible`)现按 `!= null && !== ''` 检测「是否声明了门」, 声明本身随后决定verdict:布尔在求值入口短路成自己的verdict,不交给 CEL 引擎。 这不是新决定。objectui#3492 已把同一条不变量钉在批量选择栏上, `bulkEligibility.ts` 的 `hasVisibilityGate` 注释写明真值判断答不了这个问题 (「`visible: false` is a declared gate that excludes everything」);内建 `visibleWhen` 的门一直是 `!= null`。本次只是把行动作这一族收口到同一处不变量。 两处门位: - `packages/plugin-grid/src/components/RowActionMenu.tsx` 的 `isCustomRowActionVisible` —— 同时管 overflow 菜单项、inline primary 按钮和 `planRowActionMenu` 的计数(即「⋮」触发器是否渲染,objectstack-ai#3562 的守卫); - `packages/components/src/renderers/complex/data-table.tsx` 的同名函数 —— 同时管 data-table 的行菜单项与 `planDataTableRowMenu` 的计数。 派发单按 objectstack-ai#3758 正文/分诊(锚 `b1204af`)描述为**三个**门位;PR objectstack-ai#3761 (`1a33b1aba`)此后已把 plugin-grid 的 `:130`/`:219` 两处收敛成一处共享函数, 与 objectstack-ai#3756 对 data-table 做的相同。缺陷与修法不变,门位数由 3 变 2。 行为变化面刻意窄:只有 `visible` 为字面布尔 `false`(或其它非空 falsy 值)的动作 变化 —— 从渲染变隐藏,即声明所要求的。`visible: true` 照旧渲染,`''` 与未声明 照旧不算门,表达式取值的 `visible` verdict 一律不变。`ActionSchema.visible` 是 `ExpressionInputSchema`(无 boolean 成员),`objectstack build` 产不出这个形状; 手写视图 JSON 与进程内构造 def 可以。 测试:三个观测面各一条 `visible: false` 钉子(plugin-grid overflow 项、inline 按钮、data-table 菜单项),外加守卫/plan 层三条与「⋮」DOM 两条;每条都配 `visible: true`(声明门、恒真)与 `''`/未声明(不算门)的对照断言 —— 否则 「声明检测」被写成「恒隐藏」时钉子仍会全绿。`predicate-surface-parity` 新增四条 非表达式形状的三面一致用例(此前其文件头注释把这条差异记为「still-open」)。 `RowActionMenu.emptyGuard.test.tsx` 里钉住旧真值行为的那条 fixture 整条替换: 它的期望值(`['ghost']` / `1`)现在是错的verdict,不是拼写问题。 Co-authored-by: Claude <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Part of #3562(data-table 半件——本 PR 不关闭该单;报告人那一屏的 plugin-grid 孪生半件已由 PM 按同一裁定另派,落地后由该 PR 关闭 #3562)
问题
行「更多操作」触发器的守卫数的是传入了哪些 handler,而菜单项随后又被逐项、逐记录地按谓词过滤了第二遍:
packages/components/src/renderers/complex/data-table.tsx(修改前,origin/main@b7b05da7f):而项一级的过滤在
DataTableBuiltinRowActionItem(rowEditPredicates/rowDeletePredicates的visibleWhen)和DataTableRowActionItem(自定义动作的visible)里。于是「handler 都在、但这一行的每一项都被谓词压掉」这个状态是可达的:触发器活过了守卫,菜单里却什么都不渲染 —— 一个点开是空白的按钮。修复(方案 2,对象无关)
守卫改为数真正会渲染的项,零则整个触发器不渲染。
isBuiltinRowActionVisible/isCustomRowActionVisible,planDataTableRowMenu与两个 item 组件都读它们。项与触发器因此在结构上无法再各说各话(不是靠两处写法碰巧一致)。visibleWhen/visible是按记录求值的谓词,同一张表里第一行可能保留 Edit、第二行一项不剩。表级守卫表达不了这件事,所以行菜单被抽成 per-row 组件DataTableRowActionsMenu,每行各自决定。evalRowActionVisibility走@object-ui/core的evalRowPredicate(fallback: false+warnOnError,与useRowPredicate同参),因为自定义动作的条数是变量,一项一个useRowPredicate会把 hook 数量绑到schema.rowActionDefs.length上。布尔短路照抄 plugin-gridbulkEligibility里写明的理由(objectui#3492:布尔交给引擎会 fault 并 fail-closed)。onRowDelete && (onRowEdit || custom > 0)会在两项都被压掉时留下一条孤立横线,现在按 plan 里存活的分组放。rowActions决定,本次只改单元格内部的内容 —— 没有动作可显示的行渲染一个空单元格,与「完全没接 handler 的表」历来的形态一致。测试里钉住了混合行(一行有触发器、一行没有)的td数量一致。自定义动作的
visible仍按真值判断门(visible: false会渲染),与今天的项行为逐字一致 —— 本函数存在的意义是守卫和项一致,重新裁决visible: false会改变哪些项渲染,那是另一个问题(objectui#3492 的形状),已单独记录为 #3758。登陆点更正(issue 只是线索,premise 验证结果)
分诊把落点定在本文件,但报告人那块空白 ⋮ 不在这条路径上。按
origin/main@b7b05da7f逐条核:packages/plugin-grid/src/ObjectGrid.tsx:2194——rowActions: !!(schema.editable && hasActions),注释写明「RowActionMenu column (from columnsWithActions) already handles edit/delete … Only enable DataTable's built-in action column for inline-editing save/cancel」。console 的对象列表不 editable 时,data-table 的操作单元格根本不渲染。ObjectGrid.tsx:1624-1660—— 列表自己注入一列操作列,cell 渲染RowActionMenu(plugin-grid),条件是hasActions || hasRowActions。grep -c 'onRowEdit\|onRowDelete' packages/plugin-grid/src/ObjectGrid.tsx= 0 —— ObjectGrid 从不把onRowEdit/onRowDelete/rowEditPredicates传给 data-table,所以即便操作单元格渲染了,本文件的下拉分支也拿不出任何项。ObjectGrid.tsx:1448注释:「ObjectGrid is the single convergence point of all three list callers」—— console 的三种列表调用方(含 Setup 的系统对象列表)都汇到 ObjectGrid。packages/plugin-grid/src/components/RowActionMenu.tsx:273-278:hasMenu = (canEdit && onEdit) || (canDelete && onDelete) || menuDefs.length > 0 || rowActions.length > 0—— 同样在数 handler / 声明数;项一级过滤在:130、:179、:219。sys_approval_request 在list_item上声明的动作(approve / reject / recall 等)visible是写给审批人的,admin 在「全部」视图里逐行都不满足 →hasMenu为真、0 项,与报告完全吻合。[role=menu]的children.length === 0。本文件修改前,onRowEdit与onRowDelete同时在场时会无条件渲染一条DropdownMenuSeparator,那种状态下 children 至少是 1;plugin-grid 的RowActionMenu一条分隔线都没有,全压掉正好是 0。packages/plugin-detail/src/RelatedList.tsx:1004-1042(详情页关联列表把子对象的userActions.edit/delete谓词与list_item动作喂进 data-table)—— 缺陷在这里真实可达(子记录被父状态冻结后 Edit/Delete 双双压掉即空菜单),只是不是报告人那一屏。所以:本单描述的缺陷类别成立且已在本文件修掉;本单报告人的那一屏要修 plugin-grid 的
RowActionMenu,由 PM 按同一裁定另单派发。测试
packages/components/src/renderers/complex/__tests__/data-table-row-menu-empty-guard.test.tsx(新增):[role=menu]不存在,同时操作列表头与每行空单元格仍在(本单形状);td数量相同;visible压掉 → 无触发器;planDataTableRowMenu纯函数:计数、只掉被压的那一项、存活自定义动作按声明序、disabledWhen的项仍然算数、谓词报错 fail-closed(不产生幽灵项/幽灵触发器)。既有的两套项级测试(
data-table-builtin-row-action-predicates.test.tsx/data-table-row-action-visible.test.tsx)未改动即全绿 —— item 组件改成走共享谓词函数后行为等价。反向验证(先预测后运行)
预测:把守卫换回数 handler 的旧式(
!onRowEdit && !onRowDelete && custom === 0),则「整行被压掉 → 无触发器」、「混合行触发器数 1」、「自定义动作全被压 → 无触发器」三条转红,其余(部分压掉 / 无 handler / 常规两项 / 7 条纯函数用例)保持绿 —— 它们的触发器存在性在两种守卫下相同,纯函数用例根本不经过守卫。正向(仓库根,flock 串行,
--maxWorkers=2):反向(仅把守卫那一行换回旧式):
三红三十绿,与事先写下的预测逐条一致。
其余门:
pnpm --filter @object-ui/components type-check→ 0;pnpm --filter @object-ui/components lint→ 0;node scripts/check-control-bytes.mjs→ OK(另对改动文件手工扫过控制字符类,无命中)。消费半径清查(不是只扫本包):
data-table行菜单的消费者为plugin-detail/RelatedList、plugin-dashboard、plugin-grid(仅 inline-edit 存/撤路径)与 SDUI 原生data-table;全仓 grep 触发器断言(Row actions)与rowEditPredicates|rowDeletePredicates|onRowActionDef的测试,只有plugin-detail/src/__tests__/RelatedList.rowactions.test.tsx命中,而它 mock 掉了 data-table、只断言透传的 schema,不经过本次改动。Generated by Claude Code