-
Notifications
You must be signed in to change notification settings - Fork 16.4k
fix(native-filters): clear all functionality #36882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(native-filters): clear all functionality #36882
Conversation
Nitpicks 🔍
|
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
Show resolved
Hide resolved
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
Outdated
Show resolved
Hide resolved
…rBar/index.tsx Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
…rBar/index.tsx Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
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.
Pull request overview
This PR fixes issue #36876 where the "Clear All" button in Native Filters only reset the UI form state without immediately applying the changes to the dashboard. Users had to manually click "Apply" again to see the cleared filters take effect, creating a confusing two-step process.
Key Changes
- Modified
handleClearAllto immediately dispatchupdateDataMaskactions for all cleared filters, synchronizing local component state with global Redux state - Refactored filter clearing logic to batch state updates before applying them, improving code organization
- Added immediate persistence of cleared chart customizations via
saveChartCustomizationcall
| const clearedChartCustomizations = chartCustomizationItems.map(item => ({ | ||
| ...item, | ||
| customization: { | ||
| ...item.customization, | ||
| column: null, | ||
| }, | ||
| })); | ||
|
|
||
| dispatch(saveChartCustomization(clearedChartCustomizations)); |
Copilot
AI
Jan 3, 2026
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.
The immediate call to saveChartCustomization within handleClearAll triggers an API call to persist the cleared chart customizations to the database. This changes the behavior from the previous implementation where chart customization clearing was deferred until the user clicked "Apply". While this aligns with the PR's goal of making "Clear All" immediate, it may cause unintended consequences:
- This makes an API call to update dashboard metadata immediately when "Clear All" is clicked, which could fail silently or cause race conditions with other dashboard operations
- The
saveChartCustomizationaction triggers queries for all charts (see chartCustomizationActions.ts lines 208-212), which could impact performance on dashboards with many charts - If a user clicks "Clear All" by accident, there's no way to undo since the changes are persisted immediately
Consider whether chart customization clearing should follow the same immediate-apply pattern as native filters, or if it should remain as a pending state that requires explicit confirmation. If immediate clearing is desired, ensure proper error handling is in place for the API call.
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
Outdated
Show resolved
Hide resolved
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
…rBar/index.tsx Co-authored-by: Copilot <[email protected]>
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.
Code Review Agent Run #07c9f8
Actionable Suggestions - 1
-
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx - 1
- State Update Logic Bug · Line 399-399
Review Details
-
Files reviewed - 1 · Commit Range:
ca8424e..74741c8- superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
|
|
||
| const handleClearAll = useCallback(() => { | ||
| dispatch(logEvent(LOG_ACTIONS_CHANGE_DASHBOARD_FILTER, {})); | ||
| setUpdateKey(1); |
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.
This change sets updateKey to a fixed value instead of incrementing it. In React, setting state to the same value doesn't trigger a re-render or effect. If handleClearAll is called multiple times without an intervening handleApply (which also sets to 1), subsequent calls won't update the URL parameters because the useEffect dependency on updateKey won't change. Revert to incrementing to ensure reliable triggering.
Code Review Run #07c9f8
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
|
Running CI 🤞 |
User description
Description
Fixes #36876.
Summary
The "Clear All" button in the Native Filters bar previously only reset the form UI without dispatching the corresponding updates to the Redux store. This left the dashboard in a desynchronized state where the UI appeared empty, but the charts remained filtered until the user manually clicked "Apply".
This PR updates
handleClearAllto explicitly nullify values for all active filters and dispatchupdateDataMaskimmediately. This ensures consistency between the local component state and the global Redux state, triggering the necessary dashboard refresh and correctly disabling the "Apply" button.Before/After Screenshots
Before:
FCC.New.Coder.Survey.2018.-.Comet.2026-01-01.02-34-11.mp4
After:
Superset.-.Google.Chrome.2026-01-01.04-19-01.mp4
Testing Instructions
CodeAnt-AI Description
Ensure 'Clear All' resets native filters and applies immediately
What Changed
Impact
✅ Immediate chart reloads when clearing filters✅ Fewer dashboards left in a desynced state after using Clear All✅ Disabled "Apply" when there are no pending filter changes💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.