Skip to content

Commit

Permalink
Fixed filter related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ag-m2ms committed Nov 30, 2020
1 parent 6f17ae0 commit 15b0286
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
);

// Used for MoleculeListSortFilterDialog when using textSearch
// Also used for displaying filter, since using the original would perform deadlock when creating a filter which matches
// 0 molecules
const joinedMoleculeListsCopy = useMemo(() => [...joinedMoleculeLists], [joinedMoleculeLists]);

if (!isActiveFilter) {
Expand Down Expand Up @@ -445,6 +447,12 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
}
}, [isActiveFilter, setFilterItemsHeight]);

useEffect(() => {
if (!joinedMoleculeListsCopy.length) {
dispatch(setSortDialogOpen(false));
}
}, [dispatch, joinedMoleculeListsCopy.length]);

const handleFilterChange = filter => {
const filterSet = Object.assign({}, filter);
for (let attr of MOL_ATTRIBUTES) {
Expand Down Expand Up @@ -607,7 +615,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
};

const actions = [
<FormControl className={classes.formControl} disabled={!(object_selection || []).length || sortDialogOpen}>
<FormControl className={classes.formControl} disabled={!joinedMoleculeListsCopy.length || sortDialogOpen}>
<Select
className={classes.select}
value={predefinedFilter}
Expand Down Expand Up @@ -644,7 +652,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei

<IconButton
color={'inherit'}
disabled={!(object_selection || []).length}
disabled={!joinedMoleculeListsCopy.length}
onClick={() => dispatch(hideAllSelectedMolecules(majorViewStage, joinedMoleculeLists))}
>
<Tooltip title="Hide all">
Expand All @@ -662,7 +670,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei
}
}}
color={'inherit'}
disabled={!(object_selection || []).length || predefinedFilter !== 'none'}
disabled={!joinedMoleculeListsCopy.length || predefinedFilter !== 'none'}
>
<Tooltip title="Filter/Sort">
<FilterList />
Expand Down

0 comments on commit 15b0286

Please sign in to comment.