fix(grid): 批量删除 / 按名字派发也要清掉行复选框 (#3056) - #3058
Merged
Merged
Conversation
…oo (#3056) `ObjectGrid` carries two selection sources that must move together: `selectedRows` (ours — drives the toolbar) and the data-table's internal `selectedRowIds` (drives the checkboxes, cleared only when the host bumps `selectionResetKey`). `handleBulkDialogClose` reset both; `dispatchBulkAction` reset only the first, on BOTH of its branches — the bulk-delete route through `onBulkDelete` and the by-name runner dispatch. So a successful run left the toolbar gone and every row still ticked, with no affordance to act on them. The invariant was already written down in `handleBulkDialogClose`'s comment ("ticked rows with no toolbar"); it just was not upheld on the other path. All three call sites now go through one `resetSelection()` helper, so the rule is structural instead of three places remembering to agree. Failure semantics are unchanged: an action reporting `success: false` keeps both sources so the user can retry the same rows. Reverse-control: with only ObjectGrid.tsx reverted, the two new positive assertions fail (checkboxes stay 'checked' after a successful by-name action and after a bulk delete). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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.
Fixes #3056.
症状
批量删除成功后(或按名字派发到消费方注册的 runner handler 后),选择栏消失了,但每行复选框还全勾着。用户面对的是「一堆勾选的行 + 没有任何批量操作入口」,只能逐行取消或刷新页面。
根因
ObjectGrid有两套必须同步移动的选择状态:selectedRows(自己的 state)→ 驱动BulkActionBarselectedRowIds→ 驱动行复选框,只有宿主 bumpselectionResetKey时才清空handleBulkDialogClose(富 def 那条路)两个都清;dispatchBulkAction只清了第一个,两条分支都漏——走onBulkDelete的删除分支,和按名字派发的分支。这个不变量其实早就写在
handleBulkDialogClose的注释里了,只是另一条路径没遵守:改动
三处调用点统一走一个
resetSelection()helper,把规则做成结构性的,而不是靠三个地方各自记得保持一致。失败语义没动:action 返回success: false时两套状态都保留,用户可以修好原因后重试同一批行。验证
ObjectGrid.tsx后,两条新增的正向断言全部失败——按名字 action 成功后、批量删除后,header 复选框仍是checked(应为unchecked)。plugin-grid44 文件 / 354 测试全绿;改动文件 0 lint error。注:#3002 之后这条路径变窄了——能解析到对象 action 的名字现在会被提升成 def 走对话框,所以仍然到达
dispatchBulkAction的是消费方注册的 handler 和内建的'delete'。删除是其中最常见的一条。🤖 Generated with Claude Code