question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rowHeight not refreshing while dragging

See original GitHub issue

We are working with the rowHeight-function to give the nodes different heights depending on the nested level of each node. This is working well so far.

But we ran into problems while dragging a node. The calculated heights need to be recalculated while dragging, but they don’t. We noticed this is working well with isVirtualized is false, but not if it’s set to true.

Anyone got an idea?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:31 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
dcporter44commented, Feb 4, 2019

i hacked around this by forcing calling recomputeRowHeights on drag change. On drag I set an interval at 250ms to recompute row heights. When stopped dragging, I clear the interval. I originally didnt use an interval and called recomputeRowHeights within the onChange prop, but that caused me to call recomputeRowHeights hundreds of times (for every pixel i moved my cursor while dragging). Feel free to change 250ms to a lower number. But calling recomputeRowHeights too often will hurt performance. This method isnt perfect, but it does the job:

<SortableTree>
...
reactVirtualizedListProps={{
   autoHeight: true,
   ref: ref => this.list = ref;
}}
onDragStateChanged={({ isDragging }) => {
     if (this.list) {
       const recompute = () => {
          this.list.wrappedInstance.recomputeRowHeights();
        };
        if (isDragging) {
          this.dragInterval = setInterval(recompute, 250);
        } else {
          clearInterval(this.dragInterval);
          this.list.wrappedInstance.recomputeRowHeights();
        }
    }
}}
</SortableTree>
1reaction
mx2323commented, Jun 14, 2019

i was able to get the correct behavior for refreshing row height while dragging on my own local fork of react-sortable-tree. the changes probably are not usable by anyone else, nor are they the ‘right’ way to do things, but i’m happy enough with the resulting behavior that it’s usable for us for now.

the issue is that if you modify the code to call recomputeRowHeights() more frequently like everyone is doing above, a larger and smaller row will end up toggling in the tree infinitely while you hover over a fixed location with your mouse pointer. by calling recompute row heights every time the state is changed on hover() in react-sortable-tree.js, it just exposes a problem in the library where moving variable height rows around with the current logic can cause infinite toggling of the draggedNode location.

for instance, this happens whenever a smaller height node A is hovered over the bottom portion of a larger drop target node B, A is inserted in the tree above B by the library, but on redraw, if the currently hovering node A is over B, it will try to move A down and B up. But, then on the next redraw, it will detect the node is over B, and then will try to again insert A above B, which leaves you in that infinite loop of redrawing because you are recomputing row heights

i made a change to the library in dnd-manager.js so that if it is hovering over a lower portion over a component, it will try to insert it after instead of always trying to place it above the target node.

if people are interested, i can work on a diff. it’s probably not the the right way to do this, but appears to be working good enough for our purposes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Row height not updating after sort with wrapped filtered data
I have an Excel Spreadsheet (currently running 365) with about 150 entries. The columns are filtered and some of the rows have wrapped...
Read more >
How to change and AutoFit row height in Excel - Ablebits
Here's how: To change the height of one row, drag the lower boundary of the row heading until the row is set to...
Read more >
How to Change Row Height in Excel? 5 Easy Ways
When you change the row height by clicking and dragging or by double-clicking, you will not know the height or width value you...
Read more >
How to Change Row Height in Excel (5 Easy Ways)
And when you start working with data in Excel, one of the common tasks you have to do is to ... Change the...
Read more >
Row Height: Styling & Appearance Feature of our Datagrid
Row height for pinned rows works exactly as for normal rows with one difference: it is not possible to dynamically change the height...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found