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(cross-filters): Make chart emitting cross-filter exclude itself from filtering #14046

Merged
merged 1 commit into from
Apr 12, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Apr 9, 2021

SUMMARY

When a chart emits cross-filter, the filter is applied to the chart-emitter. The result is that the user cannot add another value to that filter, because every value other than the current filter had been filtered out. This PR prevents the chart from applying a filter to itself, by adding it's ID to excluded array.
To test, enable the flag DASHBOARD_CROSS_FILTERS, go to USA Birth Names dashboard (from sample data), enable cross filtering for pie chart and try to emit a cross filter.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
https://user-images.githubusercontent.com/15073128/114161279-2b5a1e80-9928-11eb-9c1d-451519753e20.mov

After:
https://user-images.githubusercontent.com/15073128/114161311-33b25980-9928-11eb-907e-9cfd14c32eca.mov

CC: @villebro @junlincc

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Apr 9, 2021

Codecov Report

Merging #14046 (2bf8a5f) into master (a3b41e2) will not change coverage.
The diff coverage is n/a.

❗ Current head 2bf8a5f differs from pull request most recent head b929cb6. Consider uploading reports for the commit b929cb6 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14046   +/-   ##
=======================================
  Coverage   79.12%   79.12%           
=======================================
  Files         938      938           
  Lines       47523    47523           
  Branches     5940     5940           
=======================================
  Hits        37604    37604           
  Misses       9793     9793           
  Partials      126      126           
Flag Coverage Δ
cypress 56.05% <ø> (ø)
javascript 68.86% <ø> (ø)

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

Impacted Files Coverage Δ
...nd/src/dashboard/util/activeAllDashboardFilters.ts 100.00% <ø> (ø)

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 a3b41e2...b929cb6. 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.

Thanks for the fix! A quick question before approving

@@ -92,7 +92,7 @@ export const getAllActiveFilters = ({
const scope = nativeFilters?.[filterId]?.scope ??
chartConfiguration?.[filterId]?.crossFilters?.scope ?? {
rootPath: [DASHBOARD_ROOT_ID],
excluded: [],
excluded: [filterId],
Copy link
Member

Choose a reason for hiding this comment

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

Is there risk that chartConfiguration[filterId].crossFilters.scope.excluded == [], in which case the filter won't exclude itself?

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 haven't encountered such case. It's either an empty object or an array with a chart ID.

@amitmiran137 amitmiran137 merged commit bf22487 into apache:master Apr 12, 2021
amitmiran137 pushed a commit that referenced this pull request Apr 13, 2021
* master:
  fix: unable to apply logging format (#14074)
  refactor: Bootstrap to AntD - Slider (#13989)
  chore(spa refactor): refactoring dashboard to use api's instead of bootstrapdata (#13306)
  fix(listview): update listview feature flag (#13906)
  Add docs for configuring Docker Compose setup (#13961)
  feat: invalid password error message (Postgres) (#14038)
  fix: flacky test in test_update_dataset_item_w_override_columns (#14082)
  feat: Implement Celery SoftTimeLimit handling (#13740)
  feat: only send alert error emails to owners of the alert (#13862)
  feat: add descriptions to report emails (#13827)
  Make chart exclude itself from cross filtering (#14046)
  fix: fix bug when remove chart not  removing it's related cross filter data (#14081)
  feat(native-filters): Add default first value to select filter (#13726)
  feat: Make async query JWT cookie domain configurable (#14007)
  fix: add exception to catch session not having JWT (#14036)

# Conflicts:
#	superset-frontend/src/dashboard/actions/hydrate.js
#	superset/views/core.py
amitmiran137 pushed a commit that referenced this pull request Apr 13, 2021
* master: (53 commits)
  test: Adds tests to the UndoRedoKeyListeners component (#13919)
  chore: Adds dataMask reducer to reducerIndex (#13951)
  test: Tests audit for the Dashboard FilterBar (#13916)
  fix: unable to apply logging format (#14074)
  refactor: Bootstrap to AntD - Slider (#13989)
  chore(spa refactor): refactoring dashboard to use api's instead of bootstrapdata (#13306)
  fix(listview): update listview feature flag (#13906)
  Add docs for configuring Docker Compose setup (#13961)
  feat: invalid password error message (Postgres) (#14038)
  fix: flacky test in test_update_dataset_item_w_override_columns (#14082)
  feat: Implement Celery SoftTimeLimit handling (#13740)
  feat: only send alert error emails to owners of the alert (#13862)
  feat: add descriptions to report emails (#13827)
  Make chart exclude itself from cross filtering (#14046)
  fix: fix bug when remove chart not  removing it's related cross filter data (#14081)
  feat(native-filters): Add default first value to select filter (#13726)
  feat: Make async query JWT cookie domain configurable (#14007)
  fix: add exception to catch session not having JWT (#14036)
  Use consistent chart value (#14031)
  fix: Use superset generic db to catch external_metadata queries (#13974)
  ...
@junlincc junlincc added the dashboard:cross-filters Related to the Dashboard cross filters label Apr 27, 2021
@junlincc junlincc changed the title fix: Make chart emitting cross-filter exclude itself from filtering fix(cross-filters): Make chart emitting cross-filter exclude itself from filtering Apr 27, 2021
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
@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:cross-filters Related to the Dashboard cross filters release:note size/XS test:case v1.2 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants