fix(native-filters): ignore unset filter box time range #16854
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
When a dashboard has both a native time range filter AND a filter box with a date filter, the native time range filter won't apply to charts, even if the filter box is set to "No filter". This is due to the filter box taking precedence over the native filter without evaluating if it's set or not.
This PR changes this so that the filter box doesn't override the value of the native filter if its value is "No filter" (the constant
NO_TIME_RANGE
). This is done by checking that the filter box time range is set earlier in the code flow. This check was previously done when setting the filter indicator status - this logic and associated unit tests were removed as they're now handled upstream. However, if both are set, the filter box takes precedence as before. Unit tests are added to handle both cases.Closes #16839
AFTER
After this change the native time range filter applies properly:
BEFORE
Currently the native time range filter doesn't apply to a chart if the dashboard has a filter box with a date filter (see the missing
year >= 1971
in the query):TESTING INSTRUCTIONS
ADDITIONAL INFORMATION