Allow user to enter decimal values
About the issue
The fallback-query-widget-component was parsing the user-input string values into decimals (or integers, in the case of an integer input, but this wasn't a problem). This was leading to the user inputing, for example, 1.
(with the intention of writing 1.1
, but as we'd already parsed it into a decimal, we'd changed it into (1
)
About the fix
The standard way in Angular of having a form input, with a different display value from the rendered value, is via ControlValueAccessor
. So I created a small such component, and replaced the input that is being rendered in the fallback component.
This still parses the value into decimal (or integer), but still renders to the user the string value, meaning internally 1.
is saved as 1
, but in the DOM, we still show 1.
This only changes when the user defocuses from the input element, triggering the change
event, where I update the display value to be the stored value, i.e. if the user types in 1.
and then clicks away, we'll render just 1
Closes #683 (closed)