Skip to content

Commit

Permalink
#1152 - fix overflow issues when filter chips were present
Browse files Browse the repository at this point in the history
also some other minor styling stuff
  • Loading branch information
louise-davies committed May 17, 2024
1 parent 06539eb commit 1971ea4
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,45 +436,47 @@ const DatasetCardView: React.FC<DatasetCardViewProps> = (props) => {
/>
)}
</Grid>
<Grid item xs={10}>
<Grid container item xs={10} direction="column" wrap="nowrap">
<SelectedFilterChips
filters={filters}
onRemoveFilter={removeFilterChip}
/>
<Paper variant="outlined" sx={{ height: '100%', marginTop: 1 }}>
<div>
{aborted ? (
<Paper>
<Typography align="center" variant="h6" component="h6">
{t('loading.abort_message')}
</Typography>
</Paper>
) : (
<CardView
entityName="Dataset"
data={paginatedSource ?? []}
totalDataCount={
aggregatedIds?.length + (hasNextPage ? 1 : 0) ?? 0
}
onPageChange={pushPage}
onFilter={pushFilter}
onSort={handleSort}
onResultsChange={pushResults}
loadedData={!isLoading}
loadedCount={!isLoading}
filters={{}}
sort={{}}
page={page}
results={results}
title={title}
description={description}
information={information}
moreInformation={moreInformation}
buttons={buttons}
/>
)}
</div>
</Paper>
<Grid item xs>
<Paper variant="outlined" sx={{ height: '100%', marginTop: 1 }}>
<div>
{aborted ? (
<Paper>
<Typography align="center" variant="h6" component="h6">
{t('loading.abort_message')}
</Typography>
</Paper>
) : (
<CardView
entityName="Dataset"
data={paginatedSource ?? []}
totalDataCount={
aggregatedIds?.length + (hasNextPage ? 1 : 0) ?? 0
}
onPageChange={pushPage}
onFilter={pushFilter}
onSort={handleSort}
onResultsChange={pushResults}
loadedData={!isLoading}
loadedCount={!isLoading}
filters={{}}
sort={{}}
page={page}
results={results}
title={title}
description={description}
information={information}
moreInformation={moreInformation}
buttons={buttons}
/>
)}
</div>
</Paper>
</Grid>
</Grid>
</Grid>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,46 +407,48 @@ const InvestigationCardView: React.FC<InvestigationCardProps> = (props) => {
/>
)}
</Grid>
<Grid item xs={10}>
<Grid container item xs={10} direction="column" wrap="nowrap">
<SelectedFilterChips
filters={filters}
onRemoveFilter={removeFilterChip}
/>
<Paper variant="outlined" sx={{ height: '100%', marginTop: 1 }}>
<div>
{aborted ? (
<Paper>
<Typography align="center" variant="h6" component="h6">
{t('loading.abort_message')}
</Typography>
</Paper>
) : (
<CardView
entityName="Investigation"
data={paginatedSource ?? []}
totalDataCount={
aggregatedIds?.length + (hasNextPage ? 1 : 0) ?? 0
}
onPageChange={pushPage}
onFilter={pushFilter}
onSort={handleSort}
onResultsChange={pushResults}
loadedData={!isLoading}
loadedCount={!isLoading}
filters={{}}
sort={sort}
page={page}
results={results}
title={title}
description={description}
information={information}
moreInformation={moreInformation}
buttons={buttons}
allIds={aggregatedIds}
/>
)}
</div>
</Paper>
<Grid item xs>
<Paper variant="outlined" sx={{ height: '100%', marginTop: 1 }}>
<div>
{aborted ? (
<Paper>
<Typography align="center" variant="h6" component="h6">
{t('loading.abort_message')}
</Typography>
</Paper>
) : (
<CardView
entityName="Investigation"
data={paginatedSource ?? []}
totalDataCount={
aggregatedIds?.length + (hasNextPage ? 1 : 0) ?? 0
}
onPageChange={pushPage}
onFilter={pushFilter}
onSort={handleSort}
onResultsChange={pushResults}
loadedData={!isLoading}
loadedCount={!isLoading}
filters={{}}
sort={sort}
page={page}
results={results}
title={title}
description={description}
information={information}
moreInformation={moreInformation}
buttons={buttons}
allIds={aggregatedIds}
/>
)}
</div>
</Paper>
</Grid>
</Grid>
</Grid>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ function FacetPanel({
>
<Typography variant="h6">{t('facetPanel.title')}</Typography>
{showApplyButton && (
<Button onClick={onApplyFacetFilters}>{t('facetPanel.apply')}</Button>
<Button variant="contained" onClick={onApplyFacetFilters}>
{t('facetPanel.apply')}
</Button>
)}
</Box>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ function SelectedFilterChips({
aria-label={t('selectedFilters')}
direction="row"
spacing={1}
sx={{ flexWrap: 'wrap', gap: 1 }}
sx={{ flexWrap: 'wrap', rowGap: 1, ml: -1 }}
>
{Object.entries(filters).flatMap(([filterKey, filterValue]) => {
{Object.entries(filters).flatMap(([filterKey, filterValue], i) => {
if (!Array.isArray(filterValue)) return [];

return filterValue.flatMap((value) => {
return filterValue.flatMap((value, j) => {
if (typeof value === 'string') {
return [
<Chip
Expand All @@ -43,6 +43,7 @@ function SelectedFilterChips({
onDelete={() => {
onRemoveFilter(filterKey, value);
}}
sx={i === 0 && j === 0 ? { ml: 1 } : {}}
/>,
];
}
Expand All @@ -55,6 +56,7 @@ function SelectedFilterChips({
onDelete={() => {
onRemoveFilter(filterKey, value);
}}
sx={i === 0 && j === 0 ? { ml: 1 } : {}}
/>,
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ const SearchPageContainer: React.FC = () => {
}, []);

// Table should take up page but leave room for: SG appbar, SG footer,
// search box, search box padding, display as cards button, loading bar
const containerHeight = `calc(100vh - 64px - 36px - ${searchBoxHeight}px - 8px - 49px)`;
// search box, search box padding, display as cards button, loading bar, paper outline
const containerHeight = `calc(100vh - 64px - 36px - ${searchBoxHeight}px - 8px - 49px - 2px)`;

const { data: cartItems } = useCart();
const { push } = useHistory();
Expand Down Expand Up @@ -489,7 +489,11 @@ const SearchPageContainer: React.FC = () => {
data-testid="container-search-table"
id="container-search-table"
>
<DataViewPaper view={view} containerHeight={containerHeight}>
<DataViewPaper
view={view}
containerHeight={containerHeight}
variant="outlined"
>
<SearchTabs
view={view}
containerHeight={containerHeight}
Expand Down
80 changes: 39 additions & 41 deletions packages/datagateway-search/src/searchTabs/searchTabs.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,55 +220,53 @@ const SearchTabs = ({
</StyledBox>
</StyledBox>
<SearchResultCountDispatch.Provider value={dispatch}>
<Box>
<TabPanel value={currentTab} index="investigation">
{view === 'card' ? (
<InvestigationCardView hierarchy={hierarchy} />
) : (
<Paper
sx={{
height: `calc(${containerHeight} - 56px)`,
minHeight: `calc(500px - 56px)`,
overflowX: 'auto',
overflowY: 'hidden',
}}
elevation={0}
>
<InvestigationSearchTable hierarchy={hierarchy} />
</Paper>
)}
</TabPanel>
<TabPanel value={currentTab} index="dataset">
{view === 'card' ? (
<DatasetCardView hierarchy={hierarchy} />
) : (
<Paper
sx={{
height: `calc(${containerHeight} - 56px)`,
minHeight: `calc(500px - 56px)`,
overflowX: 'auto',
overflowY: 'hidden',
}}
elevation={0}
>
<DatasetSearchTable hierarchy={hierarchy} />
</Paper>
)}
</TabPanel>
<TabPanel value={currentTab} index="datafile">
<TabPanel value={currentTab} index="investigation">
{view === 'card' ? (
<InvestigationCardView hierarchy={hierarchy} />
) : (
<Paper
sx={{
height: `calc(${containerHeight} - 56px)`,
minHeight: `calc(500px - 56px)`,
overflow: 'auto',
bgcolor: 'background.default',
}}
elevation={0}
>
<InvestigationSearchTable hierarchy={hierarchy} />
</Paper>
)}
</TabPanel>
<TabPanel value={currentTab} index="dataset">
{view === 'card' ? (
<DatasetCardView hierarchy={hierarchy} />
) : (
<Paper
sx={{
height: `calc(${containerHeight} - 56px)`,
minHeight: `calc(500px - 56px)`,
overflowX: 'auto',
overflowY: 'hidden',
overflow: 'auto',
bgcolor: 'background.default',
}}
elevation={0}
>
<DatafileSearchTable hierarchy={hierarchy} />
<DatasetSearchTable hierarchy={hierarchy} />
</Paper>
</TabPanel>
</Box>
)}
</TabPanel>
<TabPanel value={currentTab} index="datafile">
<Paper
sx={{
height: `calc(${containerHeight} - 56px)`,
minHeight: `calc(500px - 56px)`,
overflow: 'auto',
bgcolor: 'background.default',
}}
elevation={0}
>
<DatafileSearchTable hierarchy={hierarchy} />
</Paper>
</TabPanel>
</SearchResultCountDispatch.Provider>
</div>
);
Expand Down
Loading

0 comments on commit 1971ea4

Please sign in to comment.