[Canvas] Fix falsey/null value bug for dropdown choices (#69290)

* Fixed falsey/null value bug for dropdown choices

* Filter only null and undefined values

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Octavio Ranieri 2020-07-06 14:49:56 -03:00 committed by GitHub
parent 5b5aa70df7
commit 21af99c9b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,8 +52,12 @@ export function dropdownControl(): ExpressionFunctionDefinition<
fn: (input, { valueColumn, filterColumn, filterGroup }) => {
let choices = [];
if (input.rows[0][valueColumn]) {
choices = uniq(input.rows.map((row) => row[valueColumn])).sort();
const filteredRows = input.rows.filter(
(row) => row[valueColumn] !== null && row[valueColumn] !== undefined
);
if (filteredRows.length > 0) {
choices = uniq(filteredRows.map((row) => row[valueColumn])).sort();
}
const column = filterColumn || valueColumn;