rsuite / rsuite-table

A React table component.
https://table.rsuitejs.com/
MIT License
727 stars 132 forks source link

Resizable column width is reset after checking cell #373

Open shyzw opened 2 years ago

shyzw commented 2 years ago

Versions

package version
react 17.0.2
rsuite-table 5.7.1

What is the expected behavior?

The column keeps width after checking cell.

What is the current behavior?

The column width is reset after checking cell.

What are the steps to reproduce?

https://user-images.githubusercontent.com/7418050/198192118-789faa7e-9d66-4344-a44f-2efd3332fe5a.mp4

Any additional comments? (optional)

simonguo commented 2 years ago

Hi @shyzw The custom column width is reset because the component re-renders when the table's children are changed. In order to save the column width, you can get the column width through the column's onResize callback, save it in the state, and let the column width be controlled.

Reference example: https://table.rsuitejs.com/#custom-cell

https://github.com/rsuite/rsuite-table/pull/374/files

shyzw commented 2 years ago

Hi @simonguo Thank you for your reply. I will try that.