fix(components): [table] expanded rows cannot be updated using array methods#23761
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughChanged the table tree store watcher to use deep watching for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hello, @rzzf, your PR title does not meet the standards, please refer to here. |
commit: |
|
Size Change: +27 B (0%) Total Size: 1.45 MB
ℹ️ View Unchanged
|
|
🧪 Playground Preview: https://element-plus.run/?pr=23761 |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
|
Should we add a test case? |
|
done |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/components/table/__tests__/table.test.ts (1)
2060-2070: Add an in-place append case here too.This only verifies the
splice/removal path. Since the regression is about array-method updates toexpandRowKeys, it would be good to also assert thatpushexpands newly added keys without replacing the whole array.Possible follow-up
wrapper.vm.expandRowKeys.splice(1, 1) await doubleWait() childRows = wrapper.findAll('.el-table__row--level-1') childRows.forEach((item, index) => { if (index < 2) { expect(item.attributes('style')).toBe('') } else { expect(item.attributes('style')).toContain('display: none') } }) + + wrapper.vm.expandRowKeys.push('1999-3-31') + await doubleWait() + childRows = wrapper.findAll('.el-table__row--level-1') + childRows.forEach((item) => { + expect(item.attributes('style') ?? '').not.toContain('display: none') + })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/components/table/__tests__/table.test.ts` around lines 2060 - 2070, Test only covered splice/removal of wrapper.vm.expandRowKeys; add an in-place append case that uses wrapper.vm.expandRowKeys.push(...) followed by await doubleWait() and then re-evaluate childRows = wrapper.findAll('.el-table__row--level-1') to assert that pushed keys cause the corresponding rows to be visible (style not containing 'display: none') while existing expanded rows remain visible (i.e., push should expand new rows without replacing the array). Update the test near the existing splice block to perform a push of a key that was previously hidden, await doubleWait(), and add expectations for both previously-expanded and newly-expanded rows using the same attribute checks as the splice assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/components/table/__tests__/table.test.ts`:
- Around line 2060-2070: Test only covered splice/removal of
wrapper.vm.expandRowKeys; add an in-place append case that uses
wrapper.vm.expandRowKeys.push(...) followed by await doubleWait() and then
re-evaluate childRows = wrapper.findAll('.el-table__row--level-1') to assert
that pushed keys cause the corresponding rows to be visible (style not
containing 'display: none') while existing expanded rows remain visible (i.e.,
push should expand new rows without replacing the array). Update the test near
the existing splice block to perform a push of a key that was previously hidden,
await doubleWait(), and add expectations for both previously-expanded and
newly-expanded rows using the same attribute checks as the splice assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 792f66df-c4d6-40ed-8061-53d96dc5067c
📒 Files selected for processing (1)
packages/components/table/__tests__/table.test.ts
|
@rzzf Thanks for your contribution! ❤️ |

Fix the first case of #23759
demo
Summary by CodeRabbit
Bug Fixes
Tests