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

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

Merged
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
29 changes: 12 additions & 17 deletions superset-frontend/src/components/FilterableTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ const FilterableTable = ({
.map(key => widthsForColumnsByKey[key])
.reduce((curr, next) => curr + next),
);
const totalTableHeight = useRef(height);
const container = useRef<HTMLDivElement>(null);

const fitTableToWidthIfNeeded = () => {
Expand Down Expand Up @@ -563,15 +562,13 @@ const FilterableTable = ({
};

const renderGrid = () => {
totalTableHeight.current = height;
if (
// exclude the height of the horizontal scroll bar from the height of the table
// and the height of the table container if the content overflows
const totalTableHeight =
container.current &&
totalTableWidth.current > container.current.clientWidth
) {
// exclude the height of the horizontal scroll bar from the height of the table
// and the height of the table container if the content overflows
totalTableHeight.current -= SCROLL_BAR_HEIGHT;
}
? height - SCROLL_BAR_HEIGHT
: height;

const getColumnWidth = ({ index }: { index: number }) =>
widthsForColumnsByKey[orderedColumnKeys[index]];
Expand Down Expand Up @@ -600,7 +597,7 @@ const FilterableTable = ({
cellRenderer={renderGridCell}
columnCount={orderedColumnKeys.length}
columnWidth={getColumnWidth}
height={totalTableHeight.current - rowHeight}
height={totalTableHeight - rowHeight}
onScroll={onScroll}
overscanColumnCount={overscanColumnCount}
overscanRowCount={overscanRowCount}
Expand Down Expand Up @@ -644,15 +641,13 @@ const FilterableTable = ({
);
}

totalTableHeight.current = height;
if (
// exclude the height of the horizontal scroll bar from the height of the table
// and the height of the table container if the content overflows
const totalTableHeight =
container.current &&
totalTableWidth.current > container.current.clientWidth
) {
// exclude the height of the horizontal scroll bar from the height of the table
// and the height of the table container if the content overflows
totalTableHeight.current -= SCROLL_BAR_HEIGHT;
}
? height - SCROLL_BAR_HEIGHT
: height;

const rowGetter = ({ index }: { index: number }) =>
getDatum(sortedAndFilteredList, index);
Expand All @@ -665,7 +660,7 @@ const FilterableTable = ({
{fitted && (
<Table
headerHeight={headerHeight}
height={totalTableHeight.current}
height={totalTableHeight}
overscanRowCount={overscanRowCount}
rowClassName={rowClassName}
rowHeight={rowHeight}
Expand Down