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): Fix "undefined" error after editing a filter #14984

Merged
merged 2 commits into from
Jun 4, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Jun 4, 2021

SUMMARY

We calculate chartsInScope and tabsInScope of native filters on first render and recalculate them only when filter's scope or dashboard's layout changes. When user edited a filter without changing it's scope, chartsInScope and tabsInScope were being set to undefined, which was causing an caused an error described in #14975.
This PR fixes it by merging edited filter into the old filter rather than overriding it. Since the edited filter object has exactly the same fields as the old filter except chartsInScope and tabsInScope, what really happens is that we override the old filter and add chartsInScope and tabsInScope fields.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: See linked issue
After:
https://user-images.githubusercontent.com/15073128/120797636-97c65800-c53c-11eb-96ac-8c34f35bb801.mov

TESTING INSTRUCTIONS

  1. Enable DASHBOARD_NATIVE_FILTERS feature flag
  2. Add a native filter
  3. Click on the filter and verify that tabs and charts in scope get highlighted
  4. Edit the filter without changing it's scope
  5. Verify that charts and tabs still get highlighted when you focus on the filter

ADDITIONAL INFORMATION

CC: @junlincc @villebro

@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #14984 (9884e86) into master (61a438a) will increase coverage by 0.08%.
The diff coverage is 100.00%.

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

@@            Coverage Diff             @@
##           master   #14984      +/-   ##
==========================================
+ Coverage   77.53%   77.62%   +0.08%     
==========================================
  Files         965      965              
  Lines       49504    49509       +5     
  Branches     6259     6260       +1     
==========================================
+ Hits        38384    38430      +46     
+ Misses      10920    10879      -41     
  Partials      200      200              
Flag Coverage Δ
javascript 72.49% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...rontend/src/filters/components/Range/buildQuery.ts 40.00% <ø> (ø)
...ontend/src/filters/components/Select/buildQuery.ts 100.00% <ø> (ø)
...et-frontend/src/dashboard/actions/nativeFilters.ts 82.69% <100.00%> (+1.84%) ⬆️
superset/models/core.py 90.00% <0.00%> (+0.26%) ⬆️
superset/connectors/sqla/models.py 89.81% <0.00%> (+1.42%) ⬆️
superset/db_engine_specs/presto.py 90.31% <0.00%> (+5.89%) ⬆️

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 61a438a...ef2f0e2. 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.

Makes sense; LGTM + tested to work, thanks for the quick fix!

@kgabryje kgabryje merged commit 8c01c13 into apache:master Jun 4, 2021
@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Jun 4, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Jun 6, 2021
* upstream/master: (68 commits)
  fix typos (apache#14950)
  docs: fix custom oauth config (apache#14997)
  fix: apply template_params on external_metadata (apache#14996)
  fix: toggle fullscreen on the dashboard (apache#14979)
  feat(native-filters): add markers and number formatter + simple tests (apache#14981)
  fix(native-filters): Fix "undefined" error after editing a filter (apache#14984)
  fix(native-filters): remove implied fetch predicate (apache#14982)
  fix(native-filters): update cascaded filter state on change (apache#14980)
  fix(filter box): replace freeform where clause with ilike (apache#14900)
  refactor: Convert TableElement.jsx component from class to functional with hooks (apache#14830)
  fix: renamed sqllab filters to _filters (apache#14971)
  feat(native-filters): apply cascading without instant filtering (apache#14966)
  chore: bump superset-ui to 0.17.53 (apache#14968)
  fix(native-filters): cascading filters not rendering in tab (apache#14964)
  feat: add type_generic and is_dttm to table metadata (apache#14863)
  additional safeguard (apache#14953)
  feat: Adding FORCE_SSL as feature flag in config.py (apache#14934)
  feat(dashboard/native-filters): Hide filters out of scope of current tab (apache#14933)
  fix: time parser truncate to first day of year/month (apache#14945)
  fix: is_temporal should overwrite is_dttm (apache#14894)
  ...
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
…ache#14984)

* fix(native-filters): Fix "undefined" error after editing a filter

* Remove console log
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
…ache#14984)

* fix(native-filters): Fix "undefined" error after editing a filter

* Remove console log
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
…ache#14984)

* fix(native-filters): Fix "undefined" error after editing a filter

* Remove console log
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.3.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 size/S 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[native-filters]Apply changes instantly in time-grain filter crashes page
4 participants