Skip to content

Commit

Permalink
fix: filterbox apply single value (#14841)
Browse files Browse the repository at this point in the history
* fix: filterbox apply single value

* fix ci

* fix e2e
  • Loading branch information
zhaoyongjie authored May 27, 2021
1 parent bd2c087 commit 9f54231
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('Dashboard filter', () => {
}
expect(requestFilter).deep.eq({
col: 'region',
op: '==',
val: 'South Asia',
op: 'IN',
val: ['South Asia'],
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ describe('Dashboard tabs', () => {
const requestParams = JSON.parse(requestBody.form_data as string);
expect(requestParams.extra_filters[0]).deep.eq({
col: 'region',
op: '==',
val: 'South Asia',
op: 'IN',
val: ['South Asia'],
});
});
});
Expand All @@ -136,8 +136,8 @@ describe('Dashboard tabs', () => {
const requestParams = JSON.parse(requestBody.form_data as string);
expect(requestParams.extra_filters[0]).deep.eq({
col: 'region',
op: '==',
val: 'South Asia',
op: 'IN',
val: ['South Asia'],
});
expect(requestParams.viz_type).eq(LINE_CHART.viz);
});
Expand All @@ -150,8 +150,8 @@ describe('Dashboard tabs', () => {
cy.wait('@v1ChartData').then(({ request }) => {
expect(request.body.queries[0].filters[0]).deep.eq({
col: 'region',
op: '==',
val: 'South Asia',
op: 'IN',
val: ['South Asia'],
});
});

Expand Down
7 changes: 3 additions & 4 deletions superset-frontend/src/visualizations/FilterBox/FilterBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { debounce } from 'lodash';
import { max as d3Max } from 'd3-array';
import { AsyncCreatableSelect, CreatableSelect } from 'src/components/Select';
import Button from 'src/components/Button';
import { t, SupersetClient } from '@superset-ui/core';
import { t, SupersetClient, ensureIsArray } from '@superset-ui/core';

import {
BOOL_FALSE_DISPLAY,
Expand Down Expand Up @@ -158,10 +158,9 @@ class FilterBox extends React.PureComponent {
if (options !== null) {
if (Array.isArray(options)) {
vals = options.map(opt => (typeof opt === 'string' ? opt : opt.value));
} else if (options.value) {
vals = options.value;
} else {
vals = options;
// must use array member for legacy extra_filters's value
vals = ensureIsArray(options.value ?? options);
}
}

Expand Down

0 comments on commit 9f54231

Please sign in to comment.