diff --git a/js/components/preview/Preview.js b/js/components/preview/Preview.js index eedae64eb..83b826793 100644 --- a/js/components/preview/Preview.js +++ b/js/components/preview/Preview.js @@ -119,6 +119,7 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => { const [molGroupsHeight, setMolGroupsHeight] = useState(0); const [filterItemsHeight, setFilterItemsHeight] = useState(0); + const [filterItemsHeightDataset, setFilterItemsHeightDataset] = useState(0); /* Hit navigator list height */ const moleculeListHeight = `calc(100vh - ${headerHeight}px - ${theme.spacing(2)}px - ${molGroupsHeight}px - ${ @@ -128,7 +129,7 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => { /* Custom dataset list height */ const customMoleculeListHeight = `calc(100vh - ${headerHeight}px - ${theme.spacing(hideProjects ? 1 : 2)}px - ${ hideProjects ? 0 : molGroupsHeight - }px - ${filterItemsHeight > 0 ? filterItemsHeight + theme.spacing(1) / 2 : 0}px - ${theme.spacing( + }px - ${filterItemsHeightDataset > 0 ? filterItemsHeightDataset + theme.spacing(1) / 2 : 0}px - ${theme.spacing( 8 )}px - ${TABS_HEADER_HEIGHT}px)`; @@ -260,8 +261,8 @@ const Preview = memo(({ isStateLoaded, hideProjects }) => { diff --git a/js/components/preview/molecule/moleculeList.js b/js/components/preview/molecule/moleculeList.js index 4b5e09f0f..14e2bdbee 100644 --- a/js/components/preview/molecule/moleculeList.js +++ b/js/components/preview/molecule/moleculeList.js @@ -58,7 +58,6 @@ import * as listType from '../../../constants/listTypes'; import { useRouteMatch } from 'react-router-dom'; import { setSortDialogOpen } from './redux/actions'; import { setCachedMolLists, setMoleculeList } from '../../../reducers/api/actions'; -import { DatasetMoleculeView } from '../../datasets/datasetMoleculeView'; import { AlertModal } from '../../common/Modal/AlertModal'; const useStyles = makeStyles(theme => ({ @@ -292,6 +291,12 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei const canLoadMore = listItemOffset < joinedMoleculeLists.length; const wereMoleculesInitialized = useRef(false); + const firstInitializationMolecule = useRef(null); + + let first = joinedMoleculeLists && joinedMoleculeLists[0]; + if (wereMoleculesInitialized.current === false && first) { + firstInitializationMolecule.current = first; + } useEffect(() => { if (proteinsHasLoaded === true || proteinsHasLoaded === null) { @@ -320,8 +325,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei wereMoleculesInitialized.current === false ) { let moleculeList = cached_mol_lists[mol_group_on]; - let firstId = joinedMoleculeLists && joinedMoleculeLists[0] && joinedMoleculeLists[0].id; - dispatch(initializeMolecules(stage, moleculeList, firstId)); + dispatch(initializeMolecules(stage, moleculeList, firstInitializationMolecule.current)); wereMoleculesInitialized.current = true; } }) @@ -339,8 +343,7 @@ export const MoleculeList = memo(({ height, setFilterItemsHeight, filterItemsHei dispatch, hideProjects, target, - proteinsHasLoaded, - joinedMoleculeLists + proteinsHasLoaded ]); useEffect(() => { diff --git a/js/components/preview/molecule/redux/dispatchActions.js b/js/components/preview/molecule/redux/dispatchActions.js index 74954664c..52f372911 100644 --- a/js/components/preview/molecule/redux/dispatchActions.js +++ b/js/components/preview/molecule/redux/dispatchActions.js @@ -309,9 +309,9 @@ export const removeLigand = (stage, data) => dispatch => { * Turn on the complex of the first ligand of the site * Turn on every ligand of the site */ -export const initializeMolecules = (majorView, moleculeList, firstId) => dispatch => { +export const initializeMolecules = (majorView, moleculeList, first) => dispatch => { if (moleculeList && majorView) { - const firstMolecule = moleculeList.find(m => m.id === firstId) || moleculeList[0]; + const firstMolecule = first || moleculeList[0]; if (firstMolecule) { dispatch(addHitProtein(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length])); dispatch(addLigand(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length], true)); diff --git a/package.json b/package.json index eaa8c2548..e987b5964 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fragalysis-frontend", - "version": "0.9.2", + "version": "0.9.5", "description": "Frontend for fragalysis", "main": "webpack.config.js", "scripts": {