Skip to content

Commit

Permalink
[Canvas] Fix falsey/null value bug for dropdown choices (elastic#69290)
Browse files Browse the repository at this point in the history
* Fixed falsey/null value bug for dropdown choices

* Filter only null and undefined values

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
octavioranieri-zz and elasticmachine authored Jul 6, 2020
1 parent 5b5aa70 commit 21af99c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 21af99c

Please sign in to comment.