codeant-ai-for-open-source[bot] commented on code in PR #43275:
URL: https://github.com/apache/superset/pull/43275#discussion_r3799894551
##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts:
##########
@@ -36,7 +37,45 @@ import {
import { useFilterConfiguration } from '../state';
export const useFilters = () => {
- const preselectedNativeFilters = useSelector<any, Filters>(
+ const preselectedNativeFilters = useSelector<RootState, Filters | undefined>(
+ state => state.dashboardState?.preselectNativeFilters,
+ );
+ const dashboardLayout = useSelector<RootState, DashboardLayout>(
+ state => state.dashboardLayout?.present || {},
+ );
+ const filterConfiguration = useFilterConfiguration();
+
+ // Exclude native filters that are already placed on the dashboard canvas
+ const canvasFilterIds = useMemo(() => {
+ const ids = new Set<string>();
+ Object.values(dashboardLayout).forEach(item => {
+ if (item?.type === FILTER_TYPE && item?.meta?.filterId) {
+ ids.add(String(item.meta.filterId));
+ }
+ });
+ return ids;
+ }, [dashboardLayout]);
+
+ return useMemo(
+ () =>
+ filterConfiguration
+ .filter(filter => !canvasFilterIds.has(filter.id))
Review Comment:
**Suggestion:** Removing canvas-bound filters from `useFilters` also removes
them from the FilterBar's state-management paths. `useFilterUpdates`
subsequently deletes their selected masks, and `handleApply` cannot include
them because its scope is derived from the filtered list. As a result, Clear
All followed by Apply cannot persist a cleared value for a canvas filter. Keep
canvas filters available to state synchronization and apply/clear operations,
while excluding them only from the rendered filter-bar list. [incomplete
implementation]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ FilterBar Clear All leaves canvas filter selections persisted.
- ⚠️ Canvas FilterHolder controls still dispatch direct updates.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6b4f8276e6334cad8dd9eeea4875eed4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6b4f8276e6334cad8dd9eeea4875eed4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/state.ts
**Line:** 61:62
**Comment:**
*Incomplete Implementation: Removing canvas-bound filters from
`useFilters` also removes them from the FilterBar's state-management paths.
`useFilterUpdates` subsequently deletes their selected masks, and `handleApply`
cannot include them because its scope is derived from the filtered list. As a
result, Clear All followed by Apply cannot persist a cleared value for a canvas
filter. Keep canvas filters available to state synchronization and apply/clear
operations, while excluding them only from the rendered filter-bar list.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=88b24feb8fb2042ebd5f4fbe6555aac58022a48ca8d5e46523e7eb6ddd378931&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=88b24feb8fb2042ebd5f4fbe6555aac58022a48ca8d5e46523e7eb6ddd378931&reaction=dislike'>👎</a>
--
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]