mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
feat: persist scroll across tabs (#7695)
* fix: persist scroll * fix: persist scroll * chore: style * fix: remove persisted variabled from localstorage on boot * fix: persist scroll in request tabs * fix: persist scroll in folder tabs * fix: hooks for container and editor scrolls * fix: persist scroll position in response tabs * fix: persist scroll for different request bodies * fix: persist scroll for collection tabs * fix: test cases * test: scroll persists tests * tests: resolved coderabbit comments for tests * tests: resolved coderabbit comments for tests * fix: remove only * fix: test cases * fix: flaky create collection path as name * move scrollbar tests * test cases * test cases * test cases * test cases * test cases * fix: moved redundant code to common useTrackScroll function * chore: spaces * fix: move usetrackscroll to hook * chore: cleanup un-needed setTimeout * fix: linting issues * chore: example fix * fix: test cases * fix: test cases * fix: flaky scroll tests cases * chore: revert prop name change * chore: blank commit * chore: blank commit --------- Co-authored-by: shubh-bruno <shubh-bruno@shubh-bruno.local> Co-authored-by: Sid <siddharth@usebruno.com>
This commit is contained in:
@@ -62,6 +62,7 @@ const EditableTable = ({
|
||||
showAddRow = true,
|
||||
testId = 'editable-table',
|
||||
columnWidths,
|
||||
initialScroll = 0,
|
||||
onColumnWidthsChange
|
||||
}) => {
|
||||
const wrapperRef = useRef(null);
|
||||
@@ -463,25 +464,30 @@ const EditableTable = ({
|
||||
);
|
||||
}, [showCheckbox, reorderable, reorderableRowCount, isLastEmptyRow, checkboxKey, disableCheckbox, handleCheckboxChange, columns, renderCell, showDelete, handleRemoveRow]);
|
||||
|
||||
const initialTopMostItemIndex = useRef(Math.max(0, Math.floor(initialScroll / ROW_HEIGHT))).current;
|
||||
|
||||
return (
|
||||
<StyledWrapper
|
||||
ref={wrapperRef}
|
||||
data-testid={testId}
|
||||
className={`${showCheckbox ? 'has-checkbox' : 'no-checkbox'} ${resizing ? 'is-resizing' : ''}`}
|
||||
>
|
||||
<TableVirtuoso
|
||||
ref={virtuosoRef}
|
||||
className="table-container"
|
||||
customScrollParent={scrollParent || undefined}
|
||||
data={rowsWithEmpty}
|
||||
components={{ TableRow }}
|
||||
context={virtuosoContext}
|
||||
defaultItemHeight={ROW_HEIGHT}
|
||||
totalListHeightChanged={handleTotalHeightChanged}
|
||||
computeItemKey={(_, item) => item.uid}
|
||||
fixedHeaderContent={fixedHeaderContent}
|
||||
itemContent={itemContent}
|
||||
/>
|
||||
{scrollParent && (
|
||||
<TableVirtuoso
|
||||
ref={virtuosoRef}
|
||||
className="table-container"
|
||||
customScrollParent={scrollParent}
|
||||
data={rowsWithEmpty}
|
||||
components={{ TableRow }}
|
||||
context={virtuosoContext}
|
||||
defaultItemHeight={ROW_HEIGHT}
|
||||
initialTopMostItemIndex={initialTopMostItemIndex}
|
||||
totalListHeightChanged={handleTotalHeightChanged}
|
||||
computeItemKey={(_, item) => item.uid}
|
||||
fixedHeaderContent={fixedHeaderContent}
|
||||
itemContent={itemContent}
|
||||
/>
|
||||
)}
|
||||
</StyledWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user