diff --git a/packages/toolpad-components/src/DataGrid.tsx b/packages/toolpad-components/src/DataGrid.tsx index 99af56cff37..84cf77e9280 100644 --- a/packages/toolpad-components/src/DataGrid.tsx +++ b/packages/toolpad-components/src/DataGrid.tsx @@ -29,6 +29,7 @@ import { styled, Typography, Tooltip, + Popover, } from '@mui/material'; import { getObjectKey } from '@mui/toolpad-core/objectKey'; import { hasImageExtension } from '@mui/toolpad-core/path'; @@ -142,6 +143,56 @@ function inferColumnType(value: unknown): string { } } +function ImageCell({ field, id, value: src }: GridRenderCellParams) { + const [anchorEl, setAnchorEl] = React.useState(null); + + const handlePopoverOpen = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget); + }; + + const handlePopoverClose = () => { + setAnchorEl(null); + }; + + const open = Boolean(anchorEl); + + const popoverId = React.useId(); + + const alt = `${field} ${id}`; + + return ( + + + + + + + ); +} + function dateValueGetter({ value }: GridValueGetterParams) { return typeof value === 'number' ? new Date(value) : value; } @@ -166,9 +217,7 @@ export const CUSTOM_COLUMN_TYPES: GridColumnTypesRecord = { ), }, image: { - renderCell: ({ field, id, value }) => ( - - ), + renderCell: ({ value, ...params }) => (value ? : ''), }, }; @@ -459,11 +508,6 @@ const DataGridComponent = React.forwardRef(function DataGridComponent( [getRowId, columns], ); - const getRowHeight = React.useMemo(() => { - const hasImageColumns = columns.some(({ type }) => type === 'image'); - return hasImageColumns ? () => 'auto' : undefined; - }, [columns]); - return (