[bug fixes] annotations <> x domains, zeros in text (#4194)

* [bugs] account for annotations in nvd3 x scale domain, fix dynamic width explore charts, allow 0 in text control

* tweak TextControl casting

* [annotations] filter separately from finding data extent
This commit is contained in:
Chris Williams
2018-03-15 15:13:24 -07:00
committed by Grace Guo
parent 7c5bc8d90c
commit e2bd40c89f
2 changed files with 46 additions and 15 deletions

View File

@@ -31,11 +31,11 @@ export default class TextControl extends React.Component {
this.onChange = this.onChange.bind(this);
}
onChange(event) {
let value = event.target.value || '';
let value = event.target.value;
// Validation & casting
const errors = [];
if (this.props.isFloat) {
if (value !== '' && this.props.isFloat) {
const error = v.numeric(value);
if (error) {
errors.push(error);
@@ -43,7 +43,7 @@ export default class TextControl extends React.Component {
value = parseFloat(value);
}
}
if (this.props.isInt) {
if (value !== '' && this.props.isInt) {
const error = v.integer(value);
if (error) {
errors.push(error);
@@ -54,7 +54,8 @@ export default class TextControl extends React.Component {
this.props.onChange(value, errors);
}
render() {
const value = this.props.value ? this.props.value.toString() : '';
const { value: rawValue } = this.props;
const value = typeof rawValue !== 'undefined' && rawValue !== null ? rawValue.toString() : '';
return (
<div>
<ControlHeader {...this.props} />