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(native-filters): set currentValue null when empty #13000

Merged
merged 2 commits into from
Feb 13, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Feb 8, 2021

SUMMARY

Currently cascading filters evaluate truthiness of the parent filter when determining if the child filter should be rendered in place of the parent. Since the native Select filter returns an empty array for an empty selection, the parent filter is determined to be set, even though it isn't.

Here we change the cascading logic so that only undefined and null are assumed to be unset. This is done because there may be other filters that have falsy values which in fact mean that the filter is set, for instance a lower range being set to 0.

SCREENSHOTS

In the example, I've constructed a cascading filter with "region" as the parent and "country" as the child. As can be seen, the "country" filter show up on the filter tab, despite the selection being empty on the "region" filter:
image

After the change, an empty selection is set as null, making the parent filter display in the filter tab:
image

TEST PLAN

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

@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Feb 8, 2021
@codecov-io
Copy link

codecov-io commented Feb 8, 2021

Codecov Report

Merging #13000 (3fa9fd3) into master (c440d98) will increase coverage by 19.72%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #13000       +/-   ##
===========================================
+ Coverage   53.17%   72.89%   +19.72%     
===========================================
  Files         449      545       +96     
  Lines       14826    20162     +5336     
  Branches     3959     5268     +1309     
===========================================
+ Hits         7884    14698     +6814     
+ Misses       6942     5339     -1603     
- Partials        0      125      +125     
Flag Coverage Δ
cypress 53.02% <100.00%> (-0.15%) ⬇️
javascript 61.86% <0.00%> (?)

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

Impacted Files Coverage Δ
...ponents/nativeFilters/FilterBar/CascadePopover.tsx 97.10% <100.00%> (+0.43%) ⬆️
...src/filters/components/Select/AntdSelectFilter.tsx 82.50% <100.00%> (-14.28%) ⬇️
...tend/src/filters/components/Select/controlPanel.ts 18.18% <0.00%> (-81.82%) ⬇️
superset-frontend/src/views/index.tsx 25.00% <0.00%> (-75.00%) ⬇️
...ntend/src/filters/components/Range/controlPanel.ts 25.00% <0.00%> (-75.00%) ⬇️
superset-frontend/src/views/App.tsx 25.58% <0.00%> (-74.42%) ⬇️
...et-frontend/src/filters/components/Select/index.ts 40.00% <0.00%> (-60.00%) ⬇️
superset-frontend/src/setup/setupPlugins.ts 44.44% <0.00%> (-55.56%) ⬇️
superset-frontend/src/setup/setupPluginsExtra.ts 50.00% <0.00%> (-50.00%) ⬇️
...rset-frontend/src/setup/setupErrorMessagesExtra.ts 50.00% <0.00%> (-50.00%) ⬇️
... and 427 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 c440d98...3fa9fd3. Read the comment docs.

@villebro villebro changed the title fix(native-filters) set currentValue null when empty fix(native-filters): set currentValue null when empty Feb 8, 2021
@@ -76,7 +76,10 @@ export default function AntdPluginFilterSelect(
),
// @ts-ignore (add to superset-ui/core)
currentState: {
value: resultValue,
value:
Array.isArray(resultValue) && resultValue.length === 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think resultValue always is array according line 60

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh nice catch! I was getting value and resultValue mixed up here.

@villebro villebro merged commit bc4c837 into apache:master Feb 13, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Feb 14, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Feb 14, 2021
* master: (30 commits)
  refactor(native-filters): decouple params from filter config modal (first phase) (apache#13021)
  fix(native-filters): set currentValue null when empty (apache#13000)
  Custom superset_config.py + secret envs (apache#13096)
  Update http error code from 400 to 403 (apache#13061)
  feat(native-filters): add storybook entry for select filter (apache#13005)
  feat(native-filters): Time native filter (apache#12992)
  Force pod restart on config changes (apache#13056)
  feat(cross-filters): add cross filters (apache#12662)
  fix(explore): Enable selecting an option not included in suggestions (apache#13029)
  Improves RTL configuration (apache#13079)
  Added a note about the ! prefix for breaking changes to CONTRIBUTING.md (apache#13083)
  chore: lock down npm to v6 (apache#13069)
  fix: API tests, make them possible to run independently again (apache#13076)
  fix: add config to disable dataset ownership on the old api (apache#13051)
  add required * indicator to message content/notif method (apache#12931)
  fix: Retroactively add granularity param to charts (apache#12960)
  fix(ci): multiline regex in change detection (apache#13075)
  feat(style): hide dashboard header by url parameter (apache#12918)
  fix(explore): pie chart label bugs (apache#13052)
  fix: Disabled state button transition time (apache#13008)
  ...
@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 dashboard:native-filters Related to the native filters of the Dashboard preset-io size/XS 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants