Commit 4c767680 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed issue with loading structures that re-use the same viewer.

parent 725ab1dc
......@@ -414,10 +414,9 @@ function Overview({section, def}) {
let system
// Do not attempt to perform visualization if size is too big
// The section is incomplete, we leave the overview empty
if (!section.atom_species) {
// the section is incomplete, we leave the overview empty
return ''
return null
}
const nAtoms = section.atom_species.length
// Loading exact same system, no need to reload visualizer
......
......@@ -117,6 +117,7 @@ export const Structure = withErrorHandler(({className, classes, system, systems,
// useRef is not guaranteed to update:
// https://reactjs.org/docs/hooks-faq.html#how-can-i-measure-a-dom-node
const refCanvas = useCallback(node => {
refCanvas.current = node
if (node === null) {
return
}
......@@ -124,7 +125,6 @@ export const Structure = withErrorHandler(({className, classes, system, systems,
return
}
refViewer.current.changeHostElement(node, true, true)
refCanvas.current = node
}, [])
// Run only on first render to initialize the viewer. See the viewer
......@@ -237,6 +237,7 @@ export const Structure = withErrorHandler(({className, classes, system, systems,
if (positionsOnly && !!(refViewer?.current?.structure)) {
refViewer.current.setPositions(finalSystem.positions)
setLoading(false)
return
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment