Skip to content

Commit

Permalink
fix: correct height calculation of listbox (#889)
Browse files Browse the repository at this point in the history
* fix: correct height calculation of listbox
  • Loading branch information
a-m-dev committed Jul 26, 2022
1 parent fb7ea43 commit 35ca9ef
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions apis/nucleus/src/components/listbox/ListBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,28 @@ export default function ListBox({
return new Promise((resolve) => {
local.current.timeout = setTimeout(
() => {
const sorted = local.current.queue.slice(-2).sort((a, b) => a.start - b.start);
const lastItemInQueue = local.current.queue.slice(-1)[0];
const reqPromise = model
.getListObjectData(
'/qListObjectDef',
sorted.map((s) => ({
qTop: s.start,
qHeight: s.stop - s.start + 1,
qLeft: 0,
qWidth: 1,
}))
// we need to ask for two payloads
// 2nd one is our starting index + MINIMUM_BATCH_SIZE items
// 1st one is 2nd ones starting index - MINIMUM_BATCH_SIZE items
// we do this because we don't want to miss any items between fast scrolls
[
{
qTop: lastItemInQueue.start > MINIMUM_BATCH_SIZE ? lastItemInQueue.start - MINIMUM_BATCH_SIZE : 0,
qHeight: MINIMUM_BATCH_SIZE,
qLeft: 0,
qWidth: 1,
},
{
qTop: lastItemInQueue.start,
qHeight: MINIMUM_BATCH_SIZE,
qLeft: 0,
qWidth: 1,
},
]
)
.then((p) => {
const processedPages = postProcessPages ? postProcessPages(p) : p;
Expand Down Expand Up @@ -244,7 +256,7 @@ export default function ListBox({
return (
<StyledInfiniteLoader
isItemLoaded={isItemLoaded}
itemCount={count}
itemCount={listCount}
loadMoreItems={loadMoreItems}
threshold={0}
minimumBatchSize={MINIMUM_BATCH_SIZE}
Expand Down

0 comments on commit 35ca9ef

Please sign in to comment.