fix(sqllab): resultset disappeared on switching tabs (#21741)

This commit is contained in:
JUST.in DO IT 2022-10-10 10:06:34 -07:00 committed by GitHub
parent 91f0de0c5d
commit d7ee443a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -332,7 +332,6 @@ const FilterableTable = ({
.map(key => widthsForColumnsByKey[key]) .map(key => widthsForColumnsByKey[key])
.reduce((curr, next) => curr + next), .reduce((curr, next) => curr + next),
); );
const totalTableHeight = useRef(height);
const container = useRef<HTMLDivElement>(null); const container = useRef<HTMLDivElement>(null);
const fitTableToWidthIfNeeded = () => { const fitTableToWidthIfNeeded = () => {
@ -563,15 +562,13 @@ const FilterableTable = ({
}; };
const renderGrid = () => { const renderGrid = () => {
totalTableHeight.current = height; // exclude the height of the horizontal scroll bar from the height of the table
if ( // and the height of the table container if the content overflows
const totalTableHeight =
container.current && container.current &&
totalTableWidth.current > container.current.clientWidth totalTableWidth.current > container.current.clientWidth
) { ? height - SCROLL_BAR_HEIGHT
// exclude the height of the horizontal scroll bar from the height of the table : height;
// and the height of the table container if the content overflows
totalTableHeight.current -= SCROLL_BAR_HEIGHT;
}
const getColumnWidth = ({ index }: { index: number }) => const getColumnWidth = ({ index }: { index: number }) =>
widthsForColumnsByKey[orderedColumnKeys[index]]; widthsForColumnsByKey[orderedColumnKeys[index]];
@ -600,7 +597,7 @@ const FilterableTable = ({
cellRenderer={renderGridCell} cellRenderer={renderGridCell}
columnCount={orderedColumnKeys.length} columnCount={orderedColumnKeys.length}
columnWidth={getColumnWidth} columnWidth={getColumnWidth}
height={totalTableHeight.current - rowHeight} height={totalTableHeight - rowHeight}
onScroll={onScroll} onScroll={onScroll}
overscanColumnCount={overscanColumnCount} overscanColumnCount={overscanColumnCount}
overscanRowCount={overscanRowCount} overscanRowCount={overscanRowCount}
@ -644,15 +641,13 @@ const FilterableTable = ({
); );
} }
totalTableHeight.current = height; // exclude the height of the horizontal scroll bar from the height of the table
if ( // and the height of the table container if the content overflows
const totalTableHeight =
container.current && container.current &&
totalTableWidth.current > container.current.clientWidth totalTableWidth.current > container.current.clientWidth
) { ? height - SCROLL_BAR_HEIGHT
// exclude the height of the horizontal scroll bar from the height of the table : height;
// and the height of the table container if the content overflows
totalTableHeight.current -= SCROLL_BAR_HEIGHT;
}
const rowGetter = ({ index }: { index: number }) => const rowGetter = ({ index }: { index: number }) =>
getDatum(sortedAndFilteredList, index); getDatum(sortedAndFilteredList, index);
@ -665,7 +660,7 @@ const FilterableTable = ({
{fitted && ( {fitted && (
<Table <Table
headerHeight={headerHeight} headerHeight={headerHeight}
height={totalTableHeight.current} height={totalTableHeight}
overscanRowCount={overscanRowCount} overscanRowCount={overscanRowCount}
rowClassName={rowClassName} rowClassName={rowClassName}
rowHeight={rowHeight} rowHeight={rowHeight}