Skip to content

Commit

Permalink
fix: edit range manually crash
Browse files Browse the repository at this point in the history
close #1124
  • Loading branch information
hamed-musallam committed Jun 14, 2021
1 parent 5337355 commit 254d10f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/component/modal/editRange/EditRangeModal.jsx
Expand Up @@ -140,7 +140,7 @@ function EditRangeModal({
_signal.multiplicity.split('').forEach((_multiplicity) => {
if (hasCouplingConstant(_multiplicity)) {
coupling = { ..._signal.j[counterJ] };
coupling.coupling = format(coupling.coupling);
coupling.coupling = Number(format(coupling.coupling));
counterJ++;
} else {
coupling = { multiplicity: _multiplicity, coupling: '' };
Expand Down
Expand Up @@ -67,15 +67,15 @@ function SignalsForm({ rangeLabel }) {
if (activeField && frequency) {
setFieldValue(
activeField,
Math.abs(event.range[0] - event.range[1]) * frequency,
Number(format(Math.abs(event.range[0] - event.range[1]) * frequency)),
);
}
});

return () => {
Events.off('brushEnd');
};
}, [activeField, setFieldValue, frequency, values.activeTab]);
}, [activeField, setFieldValue, frequency, values.activeTab, format]);

useEffect(() => {
Events.on('mouseClick', (event) => {
Expand Down Expand Up @@ -144,7 +144,7 @@ function SignalsForm({ rangeLabel }) {
// eslint-disable-next-line react/no-array-index-key
key={`signalForm${i}`}
tabid={`${i}`}
tablabel={`𝛅: ${format(signal.delta)} (${signal.j
tablabel={`𝛅: ${Number(format(signal.delta))} (${signal.j
.map((_coupling) => translateMultiplet(_coupling.multiplicity))
.join('')})`}
tabstyles={tabContainsErrors(i) ? tabStylesAddition : null}
Expand Down
1 change: 0 additions & 1 deletion src/component/panels/RangesPanel/RangesTable.jsx
Expand Up @@ -71,7 +71,6 @@ function RangesTable({
const [relativeFlags, toggleRelativeColumn] = useToggleStatus('id', data);
const [signalFlags, toggleSignalColumn] = useToggleStatus('id', data);
const { rootRef } = useGlobal();

const { items: sortedData, isSortedDesc, onSort } = useTableSortBy(data);

const isVisible = (key) => {
Expand Down
Expand Up @@ -5,7 +5,11 @@ function CouplingColumn({ rowData, onHoverSignal }) {
return (
<td {...onHoverSignal}>
{result &&
result.map((coupling) => coupling.coupling.toFixed(1)).join(',')}
result
.map((coupling) =>
!isNaN(coupling.coupling) ? coupling.coupling.toFixed(1) : '',
)
.join(',')}
</td>
);
}
Expand Down

0 comments on commit 254d10f

Please sign in to comment.