Skip to content

Commit cfb24ea

Browse files
author
David Emory
committed
fix(form): Store numeric query params (e.g. maxWalk) as numbers internally (rather than strings)
1 parent db7419f commit cfb24ea

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/actions/form.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ function planParamsToQuery (params) {
7979
query.time = params.time || getCurrentTime()
8080
break
8181
default:
82-
query[key] = params[key]
82+
if (!isNaN(params[key])) query[key] = parseFloat(params[key])
83+
else query[key] = params[key]
8384
}
8485
}
8586
return query

lib/components/form/dropdown-selector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ class DropdownSelector extends Component {
1717
}
1818

1919
_onQueryParamChange = (evt) => {
20-
this.props.setQueryParam({ [this.props.name]: evt.target.value })
20+
const val = evt.target.value
21+
this.props.setQueryParam({
22+
[this.props.name]: isNaN(val) ? val : parseFloat(val)
23+
})
2124
}
2225

2326
render () {

0 commit comments

Comments
 (0)