Skip to content

Commit

Permalink
fix: check for the nucleus before extracting info from the atom
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Jun 22, 2023
1 parent 1b37ced commit fecc3f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/component/panels/MoleculesPanel/Utilities.ts
Expand Up @@ -15,6 +15,8 @@ export interface AtomData {
}

function getElements(activeTab: string) {
if (!activeTab) return;

const nuclei = activeTab.split(',');
return nuclei.map((nucleus) => nucleus.replaceAll(/\d/g, ''));
}
Expand All @@ -37,7 +39,7 @@ export function extractFromAtom(
): AtomData {
const elements = getElements(activeTab);

if (elements.length > 0 && Object.keys(atom).length > 0) {
if (elements && elements.length > 0 && Object.keys(atom).length > 0) {
const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
switch (dim !== null && elements[dim]) {
case atom.atomLabel: {
Expand Down

0 comments on commit fecc3f8

Please sign in to comment.