Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

fix(data-table): 行「更多操作」触发器改为数「真正会渲染的项」,空则不渲染 - #3756

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-3562-row-menu-empty-guard
Aug 8, 2026
Merged

yinlianghui merged 1 commit into
mainfrom
claude/issue-3562-row-menu-empty-guard

Conversation

@yinlianghui

@yinlianghui yinlianghui commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Part of #3562(data-table 半件——本 PR 不关闭该单;报告人那一屏的 plugin-grid 孪生半件已由 PM 按同一裁定另派,落地后由该 PR 关闭 #3562)

PM 裁定(方案 A,2026-08-08):本 PR 修掉的是 data-table 行菜单守卫(真实、可达、与本单同一类缺陷,生产者为详情页关联列表);报告人所在的 console 对象列表走 plugin-grid 的 RowActionMenu(证据见下「登陆点更正」),孪生修复同裁定另单交付。

问题

行「更多操作」触发器的守卫数的是传入了哪些 handler,而菜单项随后又被逐项、逐记录地按谓词过滤了第二遍:

packages/components/src/renderers/complex/data-table.tsx(修改前,origin/main@b7b05da7f):

const customActions = Array.isArray(schema.rowActionDefs) && schema.onRowActionDef ? schema.rowActionDefs : [];
if (!schema.onRowEdit && !schema.onRowDelete && customActions.length === 0) return null;

而项一级的过滤在 DataTableBuiltinRowActionItem(rowEditPredicates / rowDeletePredicates 的 visibleWhen)和 DataTableRowActionItem(自定义动作的 visible)里。于是「handler 都在、但这一行的每一项都被谓词压掉」这个状态是可达的:触发器活过了守卫,菜单里却什么都不渲染 —— 一个点开是空白的按钮。

修复(方案 2,对象无关)

守卫改为数真正会渲染的项,零则整个触发器不渲染。

  • 谓词求值只有一处:新增 isBuiltinRowActionVisible / isCustomRowActionVisible,planDataTableRowMenu 与两个 item 组件都读它们。项与触发器因此在结构上无法再各说各话(不是靠两处写法碰巧一致)。
  • 守卫落在行级,不是表级:visibleWhen / visible 是按记录求值的谓词,同一张表里第一行可能保留 Edit、第二行一项不剩。表级守卫表达不了这件事,所以行菜单被抽成 per-row 组件 DataTableRowActionsMenu,每行各自决定。
  • 求值不用 hook:evalRowActionVisibility 走 @object-ui/core 的 evalRowPredicate(fallback: false + warnOnError,与 useRowPredicate 同参),因为自定义动作的条数是变量,一项一个 useRowPredicate 会把 hook 数量绑到 schema.rowActionDefs.length 上。布尔短路照抄 plugin-grid bulkEligibility 里写明的理由(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 逐条核:

  1. 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 的操作单元格根本不渲染。
  2. ObjectGrid.tsx:1624-1660 —— 列表自己注入一列操作列,cell 渲染 RowActionMenu(plugin-grid),条件是 hasActions || hasRowActions。
  3. grep -c 'onRowEdit\|onRowDelete' packages/plugin-grid/src/ObjectGrid.tsx = 0 —— ObjectGrid 从不把 onRowEdit / onRowDelete / rowEditPredicates 传给 data-table,所以即便操作单元格渲染了,本文件的下拉分支也拿不出任何项。
  4. ObjectGrid.tsx:1448 注释:「ObjectGrid is the single convergence point of all three list callers」—— console 的三种列表调用方(含 Setup 的系统对象列表)都汇到 ObjectGrid。
  5. 孪生缺陷在 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 项,与报告完全吻合。
  6. 旁证:报告实测 [role=menu] 的 children.length === 0。本文件修改前,onRowEdit 与 onRowDelete 同时在场时会无条件渲染一条 DropdownMenuSeparator,那种状态下 children 至少是 1;plugin-grid 的 RowActionMenu 一条分隔线都没有,全压掉正好是 0。
  7. 本文件这条路径的真实生产者是 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] 不存在,同时操作列表头与每行空单元格仍在(本单形状);
  • 只压掉一部分 → 触发器保留;
  • 完全没接 handler → 无触发器(旧行为不变);
  • 常规 Edit + Delete 两项 → 每行一个触发器(报告人的对照组不变);
  • 混合行(frozen 行无触发器 / draft 行有)→ 触发器数 1,两行 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 exec vitest run packages/components/src/renderers/complex/ --maxWorkers=2
 Test Files  7 passed (7)
      Tests  38 passed (38)

反向(仅把守卫那一行换回旧式):

 × renders NO trigger on a row whose every item is predicate-suppressed
 × mixes rows with and without a trigger while keeping the column aligned
 × suppresses the trigger when every CUSTOM action is invisible for the row
 Test Files  1 failed | 4 passed (5)
      Tests  3 failed | 30 passed (33)
AssertionError: expected [ ... ] to have a length of +0 but got 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

…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
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 8, 2026 12:02pm

Request Review

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 28.1 KB 350 KB
Entry file index-DIuSWA_x.js —
Status PASS —

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 8.66KB 3.13KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 7.57KB 2.97KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 22.10KB 4.37KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.13KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.64KB 2.21KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 35.76KB 9.11KB
auth (createAuthenticatedFetch.js) 4.37KB 1.69KB
auth (index.js) 2.35KB 1.07KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 4.91KB 0.87KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 26.07KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.65KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 481.28KB 105.96KB
core (index.js) 2.96KB 1.13KB
create-plugin (index.js) 9.84KB 3.18KB
data-objectstack (index.js) 137.51KB 35.11KB
fields (index.js) 230.90KB 56.84KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 2.65KB 1.06KB
i18n (pickLocalized.js) 1.70KB 0.83KB
i18n (provider.js) 9.48KB 3.27KB
i18n (useObjectLabel.js) 26.14KB 6.07KB
i18n (useSafeTranslation.js) 4.52KB 1.96KB
layout (index.js) 38.53KB 10.71KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 8.75KB 3.06KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.71KB 3.79KB
plugin-calendar (index.js) 44.98KB 12.37KB
plugin-charts (index.js) 61.04KB 17.31KB
plugin-chatbot (index.js) 180.09KB 42.72KB
plugin-dashboard (index.js) 115.50KB 29.96KB
plugin-designer (index.js) 210.51KB 42.51KB
plugin-detail (index.js) 232.79KB 57.42KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 112.10KB 27.10KB
plugin-gantt (index.js) 162.55KB 39.57KB
plugin-grid (index.js) 186.61KB 49.34KB
plugin-kanban (index.js) 48.30KB 13.28KB
plugin-list (index.js) 105.12KB 25.48KB
plugin-map (index.js) 16.81KB 5.24KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 40.58KB 10.58KB
plugin-timeline (index.js) 25.76KB 7.33KB
plugin-tree (index.js) 8.50KB 2.88KB
plugin-view (index.js) 84.03KB 20.55KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 19.28KB 6.38KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.02KB 0.55KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 4.47KB 2.03KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 2.71KB 1.34KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 2.59KB 1.31KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@yinlianghui
yinlianghui marked this pull request as ready for review August 8, 2026 12:08
@yinlianghui
yinlianghui added this pull request to the merge queue Aug 8, 2026
Merged via the queue into main with commit 7ed3360 Aug 8, 2026
18 checks passed
@yinlianghui
yinlianghui deleted the claude/issue-3562-row-menu-empty-guard branch August 8, 2026 12:08
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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants