-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(dashboard): Fix FilterWithDataMask typing and add null check #22260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -128,7 +128,7 @@ const FilterControls: FC<FilterControlsProps> = ({ | |||
const activeOverflowedFiltersInScope = useMemo( | |||
() => | |||
overflowedFiltersInScope.filter( | |||
filter => isNativeFilter(filter) && filter.dataMask.filterState?.value, | |||
filter => isNativeFilter(filter) && filter.dataMask?.filterState?.value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, there are isNativeFilter
and isFilterDivider
as the type guard, so I think we should introduce a new type guard for this use case, for example, isFilterWithDataMask
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #22307!
SUMMARY
This PR fixes a typing error that enabled an undefined key access error:
dataMask
isn't guaranteed to exist on typeFilterWithDataMask
because the source of that key,DataMaskStateWithId
, isn't guaranteed to have a value for each filter ID.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Example of error:

TESTING INSTRUCTIONS
I had trouble reproducing this issue locally, but try various combinations of filled and unfilled filters and ensure that it doesn't happen again.
ADDITIONAL INFORMATION
HORIZONTAL_FILTER_BAR