dosubot[bot] commented on issue #30312:
URL: https://github.com/apache/superset/issues/30312#issuecomment-2357499557
<!-- Greeting -->
Hey @FaidJalal19! I'm here to assist you with any bugs, questions, or
contributions. Let's tackle this together!
<!-- Answer -->
Native filters applied using `preselect_filters` or `native_filters` in the
URL might not take effect in the subsequent dashboard due to several potential
issues in the encoding, decoding, or application process of these filters.
The `getDashboardUrl` function is responsible for encoding these filters
into the URL. If there is an issue in this function or in how the dashboard
interprets these URL parameters, the filters may not be applied as expected.
For example, the test case:
```js
it('should process native filters key', () => {
const windowSpy = jest.spyOn(window, 'window', 'get');
windowSpy.mockImplementation(() => ({
location: {
origin: 'https://localhost',
search:
'?preselect_filters=%7B%7D&native_filters_key=024380498jdkjf-2094838',
},
}));
const urlWithNativeFilters = getDashboardUrl({
pathname: 'path',
});
expect(urlWithNativeFilters).toBe(
'path?preselect_filters=%7B%7D&native_filters_key=024380498jdkjf-2094838',
);
windowSpy.mockRestore();
});
```
This test case shows that the `native_filters_key` is being processed and
included in the URL. However, if the subsequent dashboard does not correctly
interpret this key or the `preselect_filters` parameter, the filters will not
be applied
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/util/getDashboardUrl.test.js)</sup>.
Additionally, the `useFilters` and `useNativeFiltersDataMask` hooks in the
`FilterBar` state management are responsible for handling the preselected and
native filters. The `useFilters` hook combines the preselected filters with the
native filters, while the `useNativeFiltersDataMask` hook filters and reduces
the data mask state to include only native filters. If these hooks are not
correctly processing the filters, it could also lead to the filters not being
applied as expected
<sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/nativeFilters/state.ts)</sup>.
Moreover, the `useFilterConfiguration` and `useFilterConfigMap` functions
are used to retrieve and map the dashboard's filter configuration. If these
functions do not correctly retrieve or map the filters, it could result in the
filters not being applied. The `useIsFilterInScope` and
`useSelectFiltersInScope` functions determine whether filters are in scope
based on the active tabs and the dashboard layout. If these functions do not
correctly determine the scope of the filters, it could also lead to the filters
not being applied
<sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/nativeFilters/state.ts)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]