-
Notifications
You must be signed in to change notification settings - Fork 469
Fix/resize col line stuck 4120 #5087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b91227a
fix: reset all interaction states on data update to avoid stale resiz…
Erica-cod c243c5e
docs: update changelog of rush
Erica-cod 0b8be5d
refactor: extract endResizeIfResizing() for cleaner resize cleanup in…
Erica-cod 356693c
Merge pull request #5082 from Erica-cod/fix/resize-col-line-stuck-412…
fangsmile File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@visactor/vtable/fix-resize-col-line-stuck-4120-v2_2026-03-30-02-46.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "comment": "fix: reset all interaction states on data update to avoid stale resize indicators", | ||
| "type": "patch", | ||
| "packageName": "@visactor/vtable" | ||
| } | ||
| ], | ||
| "packageName": "@visactor/vtable", | ||
| "email": "2779428708@qq.com" | ||
| } |
126 changes: 126 additions & 0 deletions
126
packages/vtable/examples/interactive/resize-setRecords.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import * as VTable from '../../src'; | ||
| import { bindDebugTool } from '../../src/scenegraph/debug-tool'; | ||
| const ListTable = VTable.ListTable; | ||
| const CONTAINER_ID = 'vTable'; | ||
|
|
||
| /** | ||
| * 验证场景:列宽/行高调整过程中调用 setRecords 或 updateOption 时, | ||
| * 调整指示线应被正确清除,不会残留在表格上。 | ||
| * 对应 issue: https://github.com/VisActor/VTable/issues/4120 | ||
| * | ||
| * 复现步骤: | ||
| * 1. 点击"自动定时刷新"按钮开启每3秒自动 setRecords | ||
| * 2. 拖动列头边界开始调整列宽(鼠标按住不放) | ||
| * 3. 等待自动刷新触发(或手动点击按钮) | ||
| * 4. 修复前:指示线会卡在表格上无法消失 | ||
| * 5. 修复后:指示线在 setRecords/updateOption 调用时被正确清除 | ||
| */ | ||
| export function createTable() { | ||
| const generatePersons = (count: number) => { | ||
| return Array.from(new Array(count)).map((_, i) => ({ | ||
| id: i + 1, | ||
| name: `员工${i + 1}`, | ||
| email: `user${i + 1}@example.com`, | ||
| department: ['研发部', '市场部', '设计部', '产品部', '运营部'][i % 5], | ||
| salary: Math.round(Math.random() * 10000 + 5000), | ||
| city: ['北京', '上海', '广州', '深圳', '杭州'][i % 5] | ||
| })); | ||
| }; | ||
|
|
||
| let records = generatePersons(100); | ||
|
|
||
| const columns: VTable.ColumnsDefine = [ | ||
| { field: 'id', title: 'ID', width: 80 }, | ||
| { field: 'name', title: '姓名', width: 120 }, | ||
| { field: 'email', title: '邮箱', width: 220 }, | ||
| { field: 'department', title: '部门', width: 120 }, | ||
| { field: 'salary', title: '薪资', width: 120 }, | ||
| { field: 'city', title: '城市', width: 120 } | ||
| ]; | ||
|
|
||
| const option: VTable.ListTableConstructorOptions = { | ||
| container: document.getElementById(CONTAINER_ID), | ||
| records, | ||
| columns, | ||
| widthMode: 'standard', | ||
| defaultRowHeight: 40, | ||
| defaultHeaderRowHeight: 50, | ||
| theme: VTable.themes.ARCO | ||
| }; | ||
|
|
||
| const btnContainer = document.createElement('div'); | ||
| btnContainer.style.cssText = 'padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;'; | ||
|
|
||
| const tip = document.createElement('span'); | ||
| tip.style.cssText = 'color: #666; font-size: 13px;'; | ||
| tip.textContent = '操作:先拖动列边界调整列宽,拖动过程中点击下方按钮'; | ||
| btnContainer.appendChild(tip); | ||
|
|
||
| const btnSetRecords = document.createElement('button'); | ||
| btnSetRecords.textContent = 'setRecords (刷新数据)'; | ||
| btnSetRecords.style.cssText = | ||
| 'padding: 6px 16px; cursor: pointer; background: #416EFF; color: #fff; border: none; border-radius: 4px;'; | ||
| btnSetRecords.addEventListener('click', () => { | ||
| records = generatePersons(100); | ||
| instance.setRecords(records); | ||
| console.log('setRecords called'); | ||
| }); | ||
| btnContainer.appendChild(btnSetRecords); | ||
|
|
||
| const btnUpdateOption = document.createElement('button'); | ||
| btnUpdateOption.textContent = 'updateOption (更新配置)'; | ||
| btnUpdateOption.style.cssText = | ||
| 'padding: 6px 16px; cursor: pointer; background: #52C41A; color: #fff; border: none; border-radius: 4px;'; | ||
| btnUpdateOption.addEventListener('click', () => { | ||
| records = generatePersons(100); | ||
| instance.updateOption({ | ||
| ...option, | ||
| records | ||
| }); | ||
| console.log('updateOption called'); | ||
| }); | ||
| btnContainer.appendChild(btnUpdateOption); | ||
|
|
||
| let timer: any = null; | ||
| const btnAutoTest = document.createElement('button'); | ||
| btnAutoTest.textContent = '自动定时刷新 (每3秒)'; | ||
| btnAutoTest.style.cssText = | ||
| 'padding: 6px 16px; cursor: pointer; background: #FA8C16; color: #fff; border: none; border-radius: 4px;'; | ||
| btnAutoTest.addEventListener('click', () => { | ||
| if (timer) { | ||
| clearInterval(timer); | ||
| timer = null; | ||
| btnAutoTest.textContent = '自动定时刷新 (每3秒)'; | ||
| btnAutoTest.style.background = '#FA8C16'; | ||
| } else { | ||
| timer = setInterval(() => { | ||
| records = generatePersons(100); | ||
| instance.setRecords(records); | ||
| console.log('auto setRecords triggered'); | ||
| }, 3000); | ||
| btnAutoTest.textContent = '停止自动刷新'; | ||
| btnAutoTest.style.background = '#FF4D4F'; | ||
| } | ||
| }); | ||
| btnContainer.appendChild(btnAutoTest); | ||
|
|
||
| document.getElementById(CONTAINER_ID)?.before(btnContainer); | ||
|
|
||
| const instance = new ListTable(option); | ||
|
|
||
| bindDebugTool(instance.scenegraph.stage as any, { | ||
| customGrapicKeys: ['role', '_updateTag'] | ||
| }); | ||
|
|
||
| const originalRelease = instance.release.bind(instance); | ||
| instance.release = () => { | ||
| if (timer) { | ||
| clearInterval(timer); | ||
| timer = null; | ||
| } | ||
| btnContainer.remove(); | ||
| originalRelease(); | ||
| }; | ||
|
|
||
| (window as any).tableInstance = instance; | ||
| } | ||
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
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
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
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
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
Oops, something went wrong.
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.
Check failure
Code scanning / CodeQL
Insecure randomness High
Copilot Autofix
AI 26 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.