react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

Togggle List not Work on Custom Dropdown

Open muhammad-ihsan opened this issue 3 years ago • 3 comments

Question Hello guys, please help i already following this instruction, but mine is not working well. Maybe something I left behind my works.

codesandbox https://codesandbox.io/s/async-morning-juy0t

muhammad-ihsan avatar Feb 07 '22 08:02 muhammad-ihsan

Could you provide a code sandbox with your implementation?

Ymbere avatar Feb 07 '22 23:02 Ymbere

@Ymbere already attached on this issue

muhammad-ihsan avatar Feb 08 '22 05:02 muhammad-ihsan

@muhammad-ihsan I could not see any problems in your code, this seems to be an issue with the toolkit provider.

When you toggle the dropdown the component re-renders, causing the reset of the internal state.

I think that for a workaround maybe you could manage the selected columns in your state instead.

I've created this example showing how you can implement it, It's made using functional components but you can adapt it to your case.

The catch is in the function customHandleToggleColumnVisibility and in the use of the property hidden in the table columns. You can check in the console that the component re-renders and the state is not lost in the process

Hope it helps

Edit snowy-violet-uzjp4

Ymbere avatar Feb 09 '22 04:02 Ymbere