Skip to content

Commit

Permalink
Fix issue with VariantTableWidget and x-data-grid filter panel alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Sep 25, 2024
1 parent aa00302 commit 5a450ce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { observer } from 'mobx-react';
import {
DataGrid,
GridColDef,
GridColumnVisibilityModel,
GridColumnVisibilityModel, GridFilterPanel,
GridPaginationModel,
GridRenderCellParams,
GridSortDirection,
Expand Down Expand Up @@ -420,13 +420,26 @@ const VariantTableWidget = observer(props => {
}
}

// NOTE: the filterPanel/sx override is added to fix an issue where the grid column filter value input doesn't align with the field and operator inputs
const gridElement = (
<DataGrid
columns={[...columns, actionsCol]}
rows={features}
density="comfortable"
slots={{
toolbar: ToolbarWithProps
toolbar: ToolbarWithProps,
filterPanel: GridFilterPanel
}}
slotProps={{
filterPanel: {
filterFormProps: {
valueInputProps: {
sx: {
marginTop: 0
}
}
}
}
}}
columnVisibilityModel={columnVisibilityModel}
pageSizeOptions={[10,25,50,100]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ScopedCssBaseline from '@mui/material/ScopedCssBaseline';
import {
DataGrid,
GridColDef,
GridColumnVisibilityModel,
GridColumnVisibilityModel, GridFilterPanel,
GridPaginationModel,
GridRenderCellParams,
GridToolbar
Expand Down Expand Up @@ -352,10 +352,22 @@ const VariantTableWidget = observer(props => {
}

const gridElement = (
// NOTE: the filterPanel/sx override is added to fix an issue where the grid column filter value input doesn't align with the field and operator inputs
<DataGrid
columns={[...gridColumns, actionsCol]}
rows={features.map((rawFeature, id) => rawFeatureToRow(rawFeature, id, gridColumns, trackId))}
slots={{ toolbar: GridToolbar }}
slots={{ toolbar: GridToolbar, filterPanel: GridFilterPanel }}
slotProps={{
filterPanel: {
filterFormProps: {
valueInputProps: {
sx: {
marginTop: 0
}
}
}
}
}}
pageSizeOptions={[10,25,50,100]}
paginationModel={ pageSizeModel }
onPaginationModelChange= {(newModel) => setPageSizeModel(newModel)}
Expand Down

0 comments on commit 5a450ce

Please sign in to comment.