Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PXWEB2-389 Dynamic heights for variable boxes #338

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ export function VariableBoxContent({
/* eslint-disable-next-line */
const TopItemListEmptyFragment = () => <></>;

//Set inital height to 44
const [calcedHeight, setCalcedHeight] = useState(44);

const handleTotalListHeightChanged = (height: number) => {
setCalcedHeight(height);
};

return (
<div className={cl(classes['variablebox-content'])}>
<div className={cl(classes['variablebox-content-main'])}>
Expand Down Expand Up @@ -355,7 +362,7 @@ export function VariableBoxContent({
{items.length > 0 && (
<Virtuoso
computeItemKey={(key) => `item-${key}`}
style={{ height: '380px', maxHeight: '380px', width: '100%' }}
style={{ height: hasSevenOrMoreValues ? 380 : Math.min(380, calcedHeight), width: '100%' }}
className=""
totalCount={items.length}
itemContent={(index) => itemRenderer(items, index)}
Expand All @@ -366,6 +373,7 @@ export function VariableBoxContent({
topItemCount={stickyTopValueCount}
ref={virtuosoRef}
onScroll={handleVirtuosoScroll}
totalListHeightChanged={handleTotalListHeightChanged}
components={{
ScrollSeekPlaceholder: ({ height }) => (
<Skeleton
Expand Down