Skip to content

Commit

Permalink
Merge pull request #70 from mit-jp/aesthetic-changes
Browse files Browse the repository at this point in the history
another attempt to fix negative decimals bug on map editor
  • Loading branch information
ethanrdsch authored Jul 8, 2024
2 parents dbbf299 + 95f2233 commit 1e4006e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions frontend/src/editor/MapOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,11 @@ function MapOptions({ mapVisualization }: { mapVisualization: MapVisualization }
value={mapVisualization.legend_ticks ?? ''}
onChange={(e) => {
let legendTicks: number | undefined = parseInt(e.target.value, 10)
if (Number.isNaN(legendTicks)) {
if (Number.isNaN(legendTicks) || legendTicks < 0) {
legendTicks = undefined
} else if (legendTicks <= 0) {
legendTicks = 0
} else if (Number.isInteger(legendTicks) && legendTicks >= 0) {
updateMap({ ...mapVisualization, legend_ticks: legendTicks })
}
updateMap({ ...mapVisualization, legend_ticks: legendTicks })
}}
/>
<TextField
Expand All @@ -211,12 +210,11 @@ function MapOptions({ mapVisualization }: { mapVisualization: MapVisualization }
value={mapVisualization.legend_decimals ?? mapVisualization.decimals}
onChange={(e) => {
let legendDecimals: number | undefined = parseInt(e.target.value, 10)
if (Number.isNaN(legendDecimals)) {
if (Number.isNaN(legendDecimals) || legendDecimals < 0) {
legendDecimals = undefined
} else if (legendDecimals <= 0) {
legendDecimals = 0
} else if (Number.isInteger(legendDecimals) && legendDecimals >= 0) {
updateMap({ ...mapVisualization, legend_decimals: legendDecimals })
}
updateMap({ ...mapVisualization, legend_decimals: legendDecimals })
}}
/>

Expand Down

0 comments on commit 1e4006e

Please sign in to comment.