fix: recompute row heights when new items are appended to DataList #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
When the last item in the list is larger than the default row size, appending more items to the list will cause the next item to bleed into the previously last item. This is because react-virtualized has the wrong value for the height of the row and hasn't been told to recompute it.
Note: There is no accompanying test for this change because testing the DataList component is prohibitively difficult due to the use of
CellMeasurer
andAutosizer
from thereact-virtualized
package. I manually verified the fix.Type
Are all requirements met?
Complete description
When starting with a list of length
n
, the item at row indexn+1
is our "load more" row. We use aCellMeasurerCache
to keep track of the heights of each row, and allowreact-virtualized
to computer the heights using aCellMeasurer
. The starting height of the last row will be the height of our "load more" row. When we append more items, the first item in the newly-appended list will not be measured because we already have a height for it (previously computed using the "load more" row). To account for this, we are now using a layout effect that fires when the list length changes, and will force a recompute for the first item in the newly appended list if our list length is increasing.Tracking Issue
flyteorg/flyte#507
Follow-up issue
NA