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

update: table ref is not the same as v4 #1470

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/subapps/dataExplorer/DataExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { useHistory } from 'react-router';
import { matchPath } from 'react-router-dom';
import { Spin, Switch } from 'antd';
import { find, merge, unionWith } from 'lodash';
import { DataExplorerTable } from './DataExplorerTable';
import { AntdTableRef, DataExplorerTable } from './DataExplorerTable';
import {
columnFromPath,
isUserColumn,
sortColumns,
useGraphAnalyticsPath,
usePaginatedExpandedResources,
} from './DataExplorerUtils';
import {
Expand Down Expand Up @@ -130,7 +129,7 @@ const DataExplorer: React.FC<{}> = () => {
const [showEmptyDataCells, setShowEmptyDataCells] = useState(true);
const [headerHeight, setHeaderHeight] = useState<number>(0);
const containerRef = useRef<HTMLDivElement>(null);
const tableRef = useRef<HTMLDivElement>(null);
const tableRef = useRef<AntdTableRef>(null);
const [typeFilterFocused, setTypeFilterFocused] = useState(false);
const handleTypeFilterFocused = (open: boolean) => setTypeFilterFocused(open);

Expand Down
5 changes: 3 additions & 2 deletions src/subapps/dataExplorer/DataExplorerTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useReducer, forwardRef } from 'react';
import React, { useEffect, useReducer, forwardRef, ElementRef } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { Resource } from '@bbp/nexus-sdk/es';
import { Empty, Table, Tooltip } from 'antd';
Expand Down Expand Up @@ -53,9 +53,10 @@ type TDateExplorerTableData = {
selectedRows: TDataSource[];
};

export type AntdTableRef = ElementRef<typeof Table>;
type TColumnNameToConfig = Map<string, ColumnType<Resource>>;
const DATA_EXPLORER_NAMESPACE = 'data-explorer';
export const DataExplorerTable = forwardRef<HTMLDivElement, TDataExplorerTable>(
export const DataExplorerTable = forwardRef<AntdTableRef, TDataExplorerTable>(
(
{
isLoading,
Expand Down
13 changes: 7 additions & 6 deletions src/subapps/dataExplorer/DateExplorerScrollArrows.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useEffect, useReducer, useRef } from 'react';
import { useEffect, useReducer } from 'react';
import { clsx } from 'clsx';
import RightSpeedArrow, {
RightArrow,
} from '../../shared/components/Icons/RightSpeedArrow';
import LeftSpeedArrow, {
LeftArrow,
} from '../../shared/components/Icons/LeftSpeedArrow';
import { TType } from '../../shared/molecules/TypeSelector/types';
import { clsx } from 'clsx';
import { AntdTableRef } from './DataExplorerTable';

type TArrowsDisplay = {
returnToStart: boolean;
Expand All @@ -22,7 +23,7 @@ type TArrowsDisplay = {
type TDateExplorerScrollArrowsProps = {
isLoading: boolean;
container: HTMLDivElement | null;
table: HTMLDivElement | null;
table: AntdTableRef | null;
orgAndProject: [string, string] | undefined;
types: TType[] | undefined;
showEmptyDataCells: boolean;
Expand Down Expand Up @@ -64,7 +65,7 @@ const DateExplorerScrollArrows = ({
window.scrollTo({ left: 0, behavior: 'smooth' });
};
const onRightArrowClick = () => {
const tableRect = table?.getBoundingClientRect();
const tableRect = table?.nativeElement.getBoundingClientRect();
const tableWidth = tableRect?.width || 0;
window.scrollTo({ left: tableWidth, behavior: 'smooth' });
};
Expand Down Expand Up @@ -95,7 +96,7 @@ const DateExplorerScrollArrows = ({
useEffect(() => {
const onScroll = (ev?: Event) => {
const containerRect = container?.getBoundingClientRect();
const tableRect = table?.getBoundingClientRect();
const tableRect = table?.nativeElement.getBoundingClientRect();
const x = containerRect?.x || 0;
const width = containerRect?.width || 0;
const tableWidth = tableRect?.width || 0;
Expand Down Expand Up @@ -136,7 +137,7 @@ const DateExplorerScrollArrows = ({
});
}, [orgAndProject, types, showEmptyDataCells, showMetadataColumns]);

const tableRect = table?.getBoundingClientRect();
const tableRect = table?.nativeElement.getBoundingClientRect();
const hideRightArrows = tableRect
? tableRect.width + tableRect.x - window.innerWidth < 60
: false;
Expand Down
6 changes: 5 additions & 1 deletion src/subapps/dataExplorer/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@
}
}

td.ant-table-cell.data-explorer-column {
box-sizing: content-box !important;
}

.data-explorer-table {
margin-bottom: 60px;

Expand All @@ -292,8 +296,8 @@
color: #8c8c8c;
height: 52px;
min-width: 72px;
width: 100%;
max-width: fit-content;
box-sizing: content-box !important;
}

.ant-table-thead > tr > th::before {
Expand Down