Enable Columns to specify custom onResizeEnd callbacks #3753
Unanswered
ryanatallah
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to save column width after it's been resized so that it becomes the new default width for future sessions. The naïve solution is to add an
onMouseUp
event to theresizer
to save the new width, like so:This method is flawed, however, because the
onMouseUp
event only fires if it occurs while the mouse is over theresizer
, which often times isn't the case if the user moves their mouse up or down beyond the header row while they're dragging left or right.What would be ideal is if we could specify
saveColumnWidth
as a callback on aColumn
(ideally specified ondefaultColumn
) for side effects when resizing is done, e.g.:Instead, we need to implement it manually. To do this, we could add a
mouseup
event listener ondocument
to detect when resizing is done, and clean up the listener when we're done:and
This is a slightly simpler implementation to what is done in
getResizerProps()
inwithColumnResizing.oldts
, which also handles touch events and passive events. For parity in coverage and to reduce the complexity of these kinds of manual solutions, it would be preferable to pass the callback intoreact-table
's internals.Beta Was this translation helpful? Give feedback.
All reactions