Fix error when clicked on filter if list is loading (#1661)
* Fix error when clicked on filter if list is loading * CR Fixes * Update tests
This commit is contained in:
parent
3fd50ee3a7
commit
ee9e55db0f
3 changed files with 14 additions and 11 deletions
|
@ -220,12 +220,14 @@ const FilterContent: React.FC<FilterContentProps> = ({
|
|||
classes={summaryClasses}
|
||||
onClick={() => handleFilterOpen(filter)}
|
||||
>
|
||||
{currentFilter && (
|
||||
<FilterContentBodyNameField
|
||||
filter={currentFilter}
|
||||
onFilterPropertyChange={action =>
|
||||
handleFilterPropertyGroupChange(action, filter)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</AccordionSummary>
|
||||
{currentFilter?.active && (
|
||||
<FilterErrorsList
|
||||
|
@ -245,7 +247,7 @@ const FilterContent: React.FC<FilterContentProps> = ({
|
|||
}
|
||||
filter={{
|
||||
...getFilterFromCurrentData(filterField),
|
||||
active: currentFilter.active
|
||||
active: currentFilter?.active
|
||||
}}
|
||||
>
|
||||
<Typography>{filterField.label}</Typography>
|
||||
|
|
|
@ -5,6 +5,7 @@ import { FilterNumericField } from "@saleor/components/Filter/FilterContent/Filt
|
|||
import { FilterSingleSelectField } from "@saleor/components/Filter/FilterContent/FilterSingleSelectField";
|
||||
import { useCommonStyles } from "@saleor/components/Filter/FilterContent/utils";
|
||||
import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField";
|
||||
import Skeleton from "@saleor/components/Skeleton";
|
||||
import { makeStyles } from "@saleor/macaw-ui";
|
||||
import classNames from "classnames";
|
||||
import React from "react";
|
||||
|
@ -60,6 +61,10 @@ const FilterContentBody: React.FC<FilterContentBodyProps> = ({
|
|||
const classes = useStyles({});
|
||||
const commonClasses = useCommonStyles({});
|
||||
|
||||
if (!filter) {
|
||||
return <Skeleton />;
|
||||
}
|
||||
|
||||
const isDateField = [FieldType.date, FieldType.dateTime].includes(
|
||||
filter.type
|
||||
);
|
||||
|
|
|
@ -28,10 +28,6 @@ const FilterContentBodyNameField: React.FC<FilterContentBodyNameFieldProps> = ({
|
|||
}) => {
|
||||
const classes = useStyles({});
|
||||
|
||||
if (!filter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
<FormControlLabel
|
||||
|
|
Loading…
Reference in a new issue