Open hana2644 opened 2 hours ago
Hello, I've fixed this issue!
This is what I've done:
I've identified the issue causing the column widths to reset after resizing. The problem was in the ResizableHeader
component where the resizeWidth
state was not being initialized with the correct width. To fix this, I've updated the ResizableHeader
component to initialize resizeWidth
with the width
prop and added a useEffect
hook to update resizeWidth
when the width
prop changes.
Here's a summary of the changes:
Initialize resizeWidth
state with the width
prop:
const [resizeWidth, setResizeWidth] = useSafeState<number>(Number(width) || 0)
Add a useEffect
hook to update resizeWidth
when width
changes:
useEffect(() => {
if (width) {
setResizeWidth(Number(width))
onColWidthChanged()
}
}, [width, shouldRender])
These changes ensure that the column widths are properly maintained after resizing and across re-renders.
I also created pull request: https://github.com/hemengke1997/use-antd-resizable-header/pull/101
[!CAUTION]
Disclaimer: This fix was created by Latta AI and you should never merge before you check the correctness of generated code!
This bug was fixed for free by Latta AI - https://latta.ai/ourmission
是样式不生效的问题