Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FilterBox): treat empty defaultValues as null #13109

Merged
merged 2 commits into from
Feb 15, 2021

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Feb 13, 2021

SUMMARY

Fixes #13099

FilterBox will send empty string as filter values when a column's defaultValue is empty string, causing no-results for filtered charts.

The default value for filter column's defaultValue is null, but if users have edited it, it will be updated to an empty string.

This empty string is then propagated to extra_filters of the affected charts. This PR will treat empty strings as null when constructing filter values for the dashboard.

This is the preferred fix because there may be existing FilterBox charts already have defaultValue: "" saved in their metadata.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

See #13099 how to reproduce the bug.

TEST PLAN

  1. Manual verification following steps in [Table]send empty filter value " " to query after default filter value is removed  #13099
  2. Added a unit test

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

[FILTER_CONFIG_ATTRIBUTES.DEFAULT_VALUE]: defaultValue,
[FILTER_CONFIG_ATTRIBUTES.CLEARABLE]: isClearable,
[FILTER_CONFIG_ATTRIBUTES.SEARCH_ALL_OPTIONS]: searchAllOptions,
} = filterConfig;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also did some light refactoring to make the code easier to read.

// empty values are ignored
if (!selectedValues[key]) {
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fix this bug:

Before

has-empty-value

After

no-empty-value

'28 days ago',
'90 days ago',
'1 year ago',
];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bycatch: this constant is not used anywhere.

@codecov-io
Copy link

codecov-io commented Feb 13, 2021

Codecov Report

Merging #13109 (390eb31) into master (2ce7982) will increase coverage by 0.36%.
The diff coverage is 57.98%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13109      +/-   ##
==========================================
+ Coverage   53.06%   53.42%   +0.36%     
==========================================
  Files         489      494       +5     
  Lines       17314    17373      +59     
  Branches     4482     4503      +21     
==========================================
+ Hits         9187     9281      +94     
+ Misses       8127     8092      -35     
Flag Coverage Δ
cypress 53.42% <57.98%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...end/src/SqlLab/components/RunQueryActionButton.tsx 52.77% <ø> (ø)
superset-frontend/src/chart/ChartContainer.jsx 100.00% <ø> (ø)
superset-frontend/src/chart/ChartRenderer.jsx 75.67% <0.00%> (-1.04%) ⬇️
...perset-frontend/src/common/components/Dropdown.tsx 50.00% <ø> (ø)
...rontend/src/components/ListView/CardSortSelect.tsx 78.94% <ø> (ø)
...ontend/src/components/ListViewCard/ImageLoader.tsx 75.00% <0.00%> (ø)
...set-frontend/src/components/URLShortLinkButton.jsx 100.00% <ø> (ø)
...rset-frontend/src/components/URLShortLinkModal.tsx 77.77% <ø> (ø)
...src/dashboard/components/FiltersBadge/selectors.ts 90.00% <ø> (ø)
...src/dashboard/components/HeaderActionsDropdown.jsx 68.49% <ø> (+0.92%) ⬆️
... and 61 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc4c837...390eb31. Read the comment docs.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for also taking the time to add a test + clean up the code.

@junlincc
Copy link
Member

junlincc commented Feb 15, 2021

Thanks for the fix and house keeping!
After I select a default filter, there's no option showing in dropdown in Filterbox or Dashboard. not sure this is related to your change.
Screen Shot 2021-02-14 at 7 21 29 PM
Screen Shot 2021-02-14 at 7 21 15 PM

@ktmud
Copy link
Member Author

ktmud commented Feb 15, 2021

@junlincc This is because the default time range filter ("Last week") was applied to your FilterBox chart. This is a legacy behavior I'm also not a fan of, but it is unrelated to this bug.

At Airbnb, we've discussed whether to allow setting a default Time Range filter per datasource as simply removing this default filter may have performance impact on some datasets, but we never had the time to follow it though. Could be a nice roadmap item, though.

@junlincc
Copy link
Member

hmm. i removed time filter but still not able to see the default value in country. @ktmud

@ktmud
Copy link
Member Author

ktmud commented Feb 15, 2021

In Explore view, default values are not displayed in the rendered chart, but they will be applied in the dashboard. This is a known issue and also a separate bug. Feel free to create a new issue to track it, or I'll do some investigation when I have time.

@villebro
Copy link
Member

@ktmud @junlincc I was also quite surprised by the default values not showing up on Explore (I haven't used them that much). I would vote for not putting effort into implementing default values in Explore view unless it's trivial, as the native select filter is almost ready for prime time and IMO provides a much cleaner UX than this component.

@junlincc
Copy link
Member

junlincc commented Feb 15, 2021

I would vote for not putting effort into implementing default values in Explore view unless it's trivial, as the native select filter is almost ready for prime time and IMO provides a much cleaner UX than this component.

I agree with @villebro . Grace and Zuzana, native filter is reaching feature parity in about 1 week. at that point, we will have our main focus on the new feature set and may not actively maintain FilterBox anymore(i don't think we will ever deprecate it though). Now is a good time to start the migration script as we discussed before.
@graceguo-supercat @zuzana-vej @ktmud

cc @amitmiran137 @simcha90

Copy link
Member

@junlincc junlincc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined not to fix the remaining issue.

Thanks for the PR again!

@junlincc junlincc merged commit 613945a into apache:master Feb 15, 2021
@junlincc junlincc added the rush! Requires immediate attention label Feb 15, 2021
@ktmud ktmud deleted the filterbox-empty-as-null branch February 17, 2021 21:54
@betodealmeida betodealmeida added v1.1 and removed rush! Requires immediate attention labels Feb 26, 2021
henryyeh pushed a commit to preset-io/superset that referenced this pull request Mar 1, 2021
* fix(FilterBox): treat empty defaultValues as null

* Add a unit test and move constant around

(cherry picked from commit 613945a)
henryyeh pushed a commit to preset-io/superset that referenced this pull request Mar 4, 2021
* fix(FilterBox): treat empty defaultValues as null

* Add a unit test and move constant around

(cherry picked from commit 613945a)
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L v1.1 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Table]send empty filter value " " to query after default filter value is removed
6 participants