Prevent text selection on column resize
Problem Description
When resizing columns, if the mouse is dragged away from the column name, the cursor changes and text is selectable. Once the text is selected, resizing is broken.
Steps to Reproduce
- Resize a column by dragging
- While dragging, move mouse downward
- Observe text being selected
- Release drag, and then attempt to resize again.
http://g.recordit.co/UEPT2gLvwl.gif
Ideally, the cursor would remain as col-resize throughout the resizing action and the text should not be selected.
Noted. Will be fixed in next version. Unfortunately there is not much of a workaround right now without overriding almost all of the resize handling. The next version will also add a class to the entire table when resizing which could then be used to address other styling needs when the table is resizing columns.
Hi @aaronschwartz, I notice that this issue is present in v7.7.0.

Is there a workaround to prevent this from happening?
@archit-p Unfortunately this issue and resolution is over 4 years old and applied to version 6 of react-table. Version 7 is a completely new library and anything that is v6 related is irrelevant to the new headless approach. Luckily, the headless approach allows much more flexibility with controlling the styling yourself.
I don't have an exact answer for you, but the approach would be to check if the table isResizing and to apply some css user-select: none so that the user cannot select text while resizing the table.
This is likely solvable as-is with v7.7.0, but if you're still having trouble you would have to open a new issue for the current version of react-table or I can help with some more details when I have time.
Thanks for the tip @aaronschwartz!
I ended up using a function to check whether any of the table's columns were resizing.
function isTableResizing() {
for (let headerGroup of headerGroups) {
for (let column of headerGroup.headers) {
if (column.isResizing) {
return true;
}
}
}
return false;
}
This is working flawlessly!
Thanks for the tip @aaronschwartz!
I ended up using a function to check whether any of the table's columns were resizing.
function isTableResizing() { for (let headerGroup of headerGroups) { for (let column of headerGroup.headers) { if (column.isResizing) { return true; } } } return false; }This is working flawlessly!
Nice! For me adding user-select: none directly to the ths seems to stop the selection from happening, even for rows below, example:
{headerGroup.headers.map((column) => {
return (
<div {...column.getHeaderProps()} className={`th ${column.isResizing ? "--resizing" : ""}`}>
{column.render("Header")}
<div {...column.getResizerProps()} className="column-resizer" />
</div>
);
})}
.resizing { user-select: none }
Thanks for the tip @aaronschwartz! I ended up using a function to check whether any of the table's columns were resizing.
function isTableResizing() { for (let headerGroup of headerGroups) { for (let column of headerGroup.headers) { if (column.isResizing) { return true; } } } return false; }This is working flawlessly!
Nice! For me adding
user-select: nonedirectly to theths seems to stop the selection from happening, even for rows below, example:{headerGroup.headers.map((column) => { return ( <div {...column.getHeaderProps()} className={`th ${column.isResizing ? "--resizing" : ""}`}> {column.render("Header")} <div {...column.getResizerProps()} className="column-resizer" /> </div> ); })}.resizing { user-select: none }
This is actually simpler than what I did. But I wanted to stop selection on the entire table, if any of the columns were resizing. Hence went with the function to check and apply classes directly to the table.