Skip to content
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
8 changes: 6 additions & 2 deletions src/components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AgGridReact } from 'ag-grid-react';
import 'ag-grid-community/styles/ag-grid.css'; // Core CSS
import 'ag-grid-community/styles/ag-theme-quartz.css'; // Theme
import './table.css';
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { ClientCellRenderer } from './cellRenderers/ClientCellRenderer';
import { CompanyCellRenderer } from './cellRenderers/CompanyCellRenderer';
import { HistoryCellRenderer } from './cellRenderers/HistoryCellRenderer';
Expand Down Expand Up @@ -57,7 +57,7 @@ export const TableCore = () => {
return stringA.localeCompare(stringB);
}
};

const tableRef = useRef<HTMLDivElement>(null);
useEffect(() => {
setRowData(appState?.clientProfileUpdates);

Expand Down Expand Up @@ -177,6 +177,9 @@ export const TableCore = () => {
key: el,
};
},
cellRendererParams: {
tableRef: tableRef,
},
},
];
});
Expand All @@ -194,6 +197,7 @@ export const TableCore = () => {
return (
<Box
className="ag-theme-quartz"
ref={tableRef}
sx={{
height:
arraysHaveSameElements(appState?.mutableSettings, appState?.settings) &&
Expand Down
37 changes: 33 additions & 4 deletions src/components/table/cellRenderers/HistoryCellRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import { FiberManualRecord } from '@mui/icons-material';
import { Box, CircularProgress, Popper, Stack, Typography } from '@mui/material';
import React, { useState } from 'react';

export const HistoryCellRenderer = ({ value }: { value: { row: any; key: string } }) => {
export const HistoryCellRenderer = ({
value,
tableRef,
}: {
value: { row: any; key: string };
tableRef: React.RefObject<HTMLDivElement>;
}) => {
const appState = useAppState();

const [loading, setLoading] = useState(false);

const [updateHistory, setUpdateHistory] = useState<any>([]);
Expand Down Expand Up @@ -132,10 +137,34 @@ export const HistoryCellRenderer = ({ value }: { value: { row: any; key: string
) : (
<></>
)}
<Popper id={id} open={open} anchorEl={anchorEl}>
<Popper
id={id}
open={open}
anchorEl={anchorEl}
modifiers={[
{
name: 'preventOverflow',
options: {
boundary: tableRef.current,
},
},
]}
>
{loading ? <CircularProgress size={20} color="inherit" /> : <HistoryList updateHistory={updateHistory} />}
</Popper>
<Popper id={multiSelectAnchorId} open={multiSelectAnchorOpen} anchorEl={multiSelectAnchor}>
<Popper
id={multiSelectAnchorId}
open={multiSelectAnchorOpen}
anchorEl={multiSelectAnchor}
modifiers={[
{
name: 'preventOverflow',
options: {
boundary: tableRef.current,
},
},
]}
>
<Stack
direction="row"
sx={(theme) => ({
Expand Down