Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FilterListItem doesn't accept object values #5559

Merged
merged 1 commit into from
Nov 23, 2020
Merged
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
6 changes: 2 additions & 4 deletions packages/ra-ui-materialui/src/list/filter/FilterListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { makeStyles } from '@material-ui/core/styles';
import CancelIcon from '@material-ui/icons/CancelOutlined';
import { useTranslate, useListFilterContext } from 'ra-core';
import { shallowEqual } from 'react-redux';
import isEqual from 'lodash/isEqual';

const useStyles = makeStyles(theme => ({
listItem: {
Expand Down Expand Up @@ -147,10 +148,7 @@ const FilterListItem: FC<{ label: string; value: any }> = props => {
const translate = useTranslate();
const classes = useStyles(props);

const isSelected = Object.keys(value).reduce(
(acc, key) => acc && value[key] == filterValues[key], // eslint-disable-line eqeqeq
true
);
const isSelected = isEqual(value, filterValues);

const addFilter = () => {
setFilters({ ...filterValues, ...value }, null, false);
Expand Down