VisActor / VisActor/VTable

[Bug] 改变表格列宽,然后更新数据,列宽会变成修改前的状态

Open
#4,336 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.7k
Forks
486
Avg merge
1d 19h
Merged PRs (30d)
16

Description

Version

1.91.6

Link to Minimal Reproduction

https://visactor.com/vtable/demo-react/component/custom-component

Steps to Reproduce

Image

改表格列宽,然后给表格添加数据等操作,列宽会变成修改前的状态,页面出现跳动。

// import * as ReactVTable from '@visactor/react-vtable';

const { useCallback, useRef, useState, useEffect } = React;
const { ListTable, CustomComponent } = ReactVTable;
const { Popconfirm, Message, Button } = ArcoDesign;

function Tooltip(props) {
return (
<div style={{ width: '100%', height: '100%', border: '1px solid #333', backgroundColor: '#ccc', fontSize: 10 }}>
{${props.value}(click to show more)}

);
}

function App() {
const [hoverCol, setHoverCol] = useState(-1);
const [hoverRow, setHoverRow] = useState(-1);
const [clickCol, setClickCol] = useState(-1);
const [clickRow, setClickRow] = useState(-1);
const [value, setValue] = useState('');
const visible = useRef(false);
const tableInstance = useRef(null);
const [records, setRecords] = useState([])
useEffect(()=> {
setRecords(new Array(1000).fill(['张三', 18, '男', '🏀']))
},[])
const option = {
columns: [
{
field: '0',
title: '名称'
},
{
field: '1',
title: '年龄'
},
{
field: '2',
title: '性别'
},
{
field: '3',
title: '爱好'
}
],
records,
};

const updateHoverPos = useCallback(args => {
if (visible.current) {
return;
}
setHoverCol(args.col);
setHoverRow(args.row);
const cellValue = tableInstance.current.getCellValue(args.col, args.row);
setValue(cellValue);
}, []);
const hide = useCallback(() => {
setHoverCol(-1);
setHoverRow(-1);
}, []);

const updateClickPos = useCallback(args => {
setClickCol(args.col);
setClickRow(args.row);
}, []);

const ready = (instance, isInitial) => {
if (isInitial) {
tableInstance.current = instance;
}
};

return (





<Popconfirm
focusLock
title="Popconfirm"
content="Click component!"
onOk={() => {
Message.info({
content: 'ok'
});
setClickCol(-1);
setClickRow(-1);
setRecords([['Tom', 20, 'male', '$$', 'beijing'], ...records])
}}
onCancel={() => {
Message.error({
content: 'cancel'
});
setClickCol(-1);
setClickRow(-1);
}}
onVisibleChange={popVisible => {
visible.current = popVisible;
}}
>
<Button style={{ width: '100%', height: '100%' }}>Click



);
}

const root = ReactDom.createRoot(document.getElementById(CONTAINER_ID));
root.render();

// release react instance, do not copy
window.customRelease = () => {
root.unmount();
};

Current Behavior

改表格列宽,然后给表格添加数据等操作,列宽会变成修改前的状态,页面出现跳动。

Expected Behavior

改表格列宽,然后给表格添加数据等操作,列宽是修改后的状态,而不是变成修改前的状态。

Environment
- OS:
- Browser:
- Framework:
Any additional comments?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked React ListTable reproduction using CustomComponent and confirm the sequence of resizing a column followed by a records update. Trace the ListTable update path to identify where the resized width is lost; done means the updated table keeps the new width without visible jumping.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.