Skip to content

Commit e8faddc

Browse files
fix: return empty string when FWHM, mu, or gamma is missing or invalid
1 parent 691d07c commit e8faddc

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/component/panels/PeaksPanel/PeaksTable.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ export function usePeaksTableColumns(activeTab: string) {
110110
accessor: (row) => row?.shape?.fwhm || '',
111111
Cell: ({ row }: CellProps<PeakRecord>) => {
112112
const fwhm = row.original?.shape?.fwhm;
113-
if (fwhm) {
114-
return formatNumber(fwhm, tablePreferences.fwhm.format);
113+
if (typeof fwhm !== 'number') {
114+
return '';
115115
}
116-
return '';
116+
return formatNumber(fwhm, tablePreferences.fwhm.format);
117117
},
118118
},
119119
{
@@ -126,10 +126,10 @@ export function usePeaksTableColumns(activeTab: string) {
126126
const mu =
127127
row.original?.shape?.kind === 'pseudoVoigt' &&
128128
row.original?.shape?.mu;
129-
if (mu) {
130-
return formatNumber(mu, tablePreferences.mu.format);
129+
if (typeof mu !== 'number') {
130+
return '';
131131
}
132-
return '';
132+
return formatNumber(mu, tablePreferences.mu.format);
133133
},
134134
},
135135
{
@@ -143,10 +143,12 @@ export function usePeaksTableColumns(activeTab: string) {
143143
const gamma =
144144
row.original?.shape?.kind === 'generalizedLorentzian' &&
145145
row.original?.shape?.gamma;
146-
if (gamma) {
147-
return formatNumber(gamma, tablePreferences.gamma.format);
146+
147+
if (typeof gamma !== 'number') {
148+
return '';
148149
}
149-
return '';
150+
151+
return formatNumber(gamma, tablePreferences.gamma.format);
150152
},
151153
},
152154
{

0 commit comments

Comments
 (0)