You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2023/07/28 13:56:58 UTC
[superset] branch master updated: fix: Removes unnecessary query on filters (#24814)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 5bb8e0da89 fix: Removes unnecessary query on filters (#24814)
5bb8e0da89 is described below
commit 5bb8e0da897e62382807cc374d2cc3b5a6e2de03
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Fri Jul 28 10:56:51 2023 -0300
fix: Removes unnecessary query on filters (#24814)
---
.../components/Select/SelectFilterPlugin.test.tsx | 47 +++++++++++-----------
.../components/Select/SelectFilterPlugin.tsx | 17 +-------
2 files changed, 24 insertions(+), 40 deletions(-)
diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
index f0aa4453b1..c035f81c01 100644
--- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
+++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
@@ -235,34 +235,33 @@ describe('SelectFilterPlugin', () => {
});
});
- test('Add ownState with column types when search all options', async () => {
+ test('receives the correct filter when search all options', async () => {
getWrapper({ searchAllOptions: true, multiSelect: false });
userEvent.click(screen.getByRole('combobox'));
expect(await screen.findByRole('combobox')).toBeInTheDocument();
userEvent.click(screen.getByTitle('girl'));
- expect(setDataMask).toHaveBeenCalledWith({
- __cache: {
- value: ['boy'],
- },
- extraFormData: {
- filters: [
- {
- col: 'gender',
- op: 'IN',
- val: ['girl'],
- },
- ],
- },
- filterState: {
- label: 'girl',
- value: ['girl'],
- },
- ownState: {
- coltypeMap: {
- gender: 1,
+ expect(setDataMask).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ extraFormData: {
+ filters: [
+ {
+ col: 'gender',
+ op: 'IN',
+ val: ['girl'],
+ },
+ ],
},
- search: null,
- },
- });
+ }),
+ );
+ });
+ test('number of fired queries when searching', async () => {
+ getWrapper({ searchAllOptions: true });
+ userEvent.click(screen.getByRole('combobox'));
+ expect(await screen.findByRole('combobox')).toBeInTheDocument();
+ await userEvent.type(screen.getByRole('combobox'), 'a');
+ // Closes the select
+ userEvent.tab();
+ // One call for the search term and other for the empty search
+ expect(setDataMask).toHaveBeenCalledTimes(2);
});
});
diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
index 0ebcb03a5d..2c5d919188 100644
--- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
@@ -185,23 +185,9 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
[dispatchDataMask, initialColtypeMap, searchAllOptions],
);
- const clearSuggestionSearch = useCallback(() => {
- setSearch('');
- if (searchAllOptions) {
- dispatchDataMask({
- type: 'ownState',
- ownState: {
- coltypeMap: initialColtypeMap,
- search: null,
- },
- });
- }
- }, [dispatchDataMask, initialColtypeMap, searchAllOptions]);
-
const handleBlur = useCallback(() => {
- clearSuggestionSearch();
unsetFocusedFilter();
- }, [clearSuggestionSearch, unsetFocusedFilter]);
+ }, [unsetFocusedFilter]);
const handleChange = useCallback(
(value?: SelectValue | number | string) => {
@@ -323,7 +309,6 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
mode={multiSelect ? 'multiple' : 'single'}
placeholder={placeholderText}
onSearch={onSearch}
- onSelect={clearSuggestionSearch}
onBlur={handleBlur}
onFocus={setFocusedFilter}
onMouseEnter={setHoveredFilter}