fix: Missing applied filters indicator #22137
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
This PR fixes a bug which is exemplifies all that is wrong with Superset. Spaghetti code (exacerbated by the fact that the native and legacy filters use different form-data encodings) and half baked features—legacy charts vs. ECharts.
Specifically this issue—where the applied filter indicator is missing—seems to only surface for NVD3TimeSeriesViz charts with time comparisons using the non-native temporal filters. The non-native filters seem to encode which filters are applied using the applied_time_extras form-data field which is defined in the merge_extra_filters method via an extraction of the
extra_filters
field—which is then disposed of.The problem lies when this method is called multiple times. This the case when Advanced Analytics are used which requires running extra queries and re-evaluating the query object thus re-invoking the
merge_extra_filters
method, however this time with theextra_filters
field missing from the form-data. The result is theapplied_time_extras
is now empty which translates to the filter indicator not reflecting that the temporal field has been defined. The solution is merely to preserve (as opposed to overwrite) theapplied_time_extras
field.Note this issue only impacted the applied filter indicator, i.e., the filters were correctly applied to the underlying chart.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE
AFTER
TESTING INSTRUCTIONS
Added unit tests and tested locally.
ADDITIONAL INFORMATION