Skip to content

Commit

Permalink
Fix query based parameter has value null when created (getredash#3707)
Browse files Browse the repository at this point in the history
* Fix query based parameter value null when created

* Use toString to avoid having 'null' string
  • Loading branch information
gabrieldutra authored and harveyrendell committed Nov 14, 2019
1 parent 1bdc11a commit 1be5276
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions client/app/components/QueryBasedParameterInput.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { find, isFunction } from 'lodash';
import { find, isFunction, toString } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import { react2angular } from 'react2angular';
Expand Down Expand Up @@ -35,10 +35,9 @@ export class QueryBasedParameterInput extends React.Component {
this._loadOptions(this.props.queryId);
}

// eslint-disable-next-line no-unused-vars
componentWillReceiveProps(nextProps) {
if (nextProps.queryId !== this.props.queryId) {
this._loadOptions(nextProps.queryId, nextProps.value);
componentDidUpdate(prevProps) {
if (this.props.queryId !== prevProps.queryId) {
this._loadOptions(this.props.queryId);
}
}

Expand Down Expand Up @@ -68,7 +67,7 @@ export class QueryBasedParameterInput extends React.Component {
className={className}
disabled={loading || (options.length === 0)}
loading={loading}
defaultValue={'' + value}
value={toString(value)}
onChange={onSelect}
dropdownMatchSelectWidth={false}
dropdownClassName="ant-dropdown-in-bootstrap-modal"
Expand Down

0 comments on commit 1be5276

Please sign in to comment.