Skip to content

Conversation

@vighneshtule
Copy link

@vighneshtule vighneshtule commented Dec 31, 2025

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 handleClearAll to explicitly nullify values for all active filters and dispatch updateDataMask immediately. 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
  • "Clear All" reset the input inputs but did not trigger a chart reload.
  • The "Apply" button remained active/enabled, requiring a second click.

After:

Superset.-.Google.Chrome.2026-01-01.04-19-01.mp4
  • "Clear All" immediately resets inputs and reloads charts with the unfiltered dataset.
  • The "Apply" button is correctly disabled, indicating no pending changes.

Testing Instructions

  1. Open a dashboard with Native Filters.
  2. Apply a filter value (e.g., Country: Argentina).
  3. Click "Apply" -> Charts update.
  4. Click "Clear All".
  5. Verify: Charts reload immediately, and the "Apply" button is disabled.

CodeAnt-AI Description

Ensure 'Clear All' resets native filters and applies immediately

What Changed

  • "Clear All" now clears all native filters' values globally and immediately applies those changes so charts reload without extra clicks
  • The component state and global filter state are synchronized when clearing, preventing UI inputs from appearing cleared while charts remain filtered
  • Chart-level customizations are cleared and saved when present, ensuring charts reflect the uncustomized state after clearing

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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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.

@dosubot dosubot bot added the dashboard:native-filters Related to the native filters of the Dashboard label Dec 31, 2025
@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:M This PR changes 30-99 lines, ignoring generated files label Dec 31, 2025
@codeant-ai-for-open-source
Copy link
Contributor

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Behavioral Issue
    setUpdateKey(1) is used to trigger side effects (publishing the data mask). Setting to a fixed value may not trigger updates if updateKey is already 1 (subsequent clears/applies won't change the value). Use an incrementing pattern to reliably trigger dependent effects.

  • Semantics Change
    The code now sets cleared filter values to null instead of undefined. Other parts of the codebase use undefined to detect "uninitialized" vs "cleared" states. Switching to null may change initialization and default behavior (e.g., default-to-first-item logic, validation). Verify this is intentional and doesn't break initialization guards.

  • Possible Bug
    The code dispatches updateDataMask with mask.id extracted from the mask object. There's no guarantee the mask object contains an id property (previous code used the map key as the filter id). If mask.id is undefined the action will be dispatched with an invalid id and filters won't be updated correctly.

vighneshtule and others added 2 commits January 1, 2026 04:35
…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>
@apache apache deleted a comment from bito-code-review bot Jan 3, 2026
@apache apache deleted a comment from codeant-ai-for-open-source bot Jan 3, 2026
@apache apache deleted a comment from codeant-ai-for-open-source bot Jan 3, 2026
@apache apache deleted a comment from codeant-ai-for-open-source bot Jan 3, 2026
@apache apache deleted a comment from bito-code-review bot Jan 3, 2026
@apache apache deleted a comment from codeant-ai-for-open-source bot Jan 3, 2026
@rusackas rusackas requested a review from Copilot January 3, 2026 07:04
Copy link
Contributor

Copilot AI left a 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 handleClearAll to immediately dispatch updateDataMask actions 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 saveChartCustomization call

Comment on lines +463 to +471
const clearedChartCustomizations = chartCustomizationItems.map(item => ({
...item,
customization: {
...item.customization,
column: null,
},
}));

dispatch(saveChartCustomization(clearedChartCustomizations));
Copy link

Copilot AI Jan 3, 2026

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:

  1. 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
  2. The saveChartCustomization action triggers queries for all charts (see chartCustomizationActions.ts lines 208-212), which could impact performance on dashboards with many charts
  3. 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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a 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.

Copy link
Contributor

@bito-code-review bito-code-review bot left a 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
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

AI Code Review powered by Bito Logo


const handleClearAll = useCallback(() => {
dispatch(logEvent(LOG_ACTIONS_CHANGE_DASHBOARD_FILTER, {}));
setUpdateKey(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State Update Logic Bug

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

@apache apache deleted a comment from codeant-ai-for-open-source bot Jan 5, 2026
@rusackas
Copy link
Member

rusackas commented Jan 5, 2026

Running CI 🤞

@vighneshtule vighneshtule changed the title Fix/native filters clear all fix(native-filters): clear all functionality Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard:native-filters Related to the native filters of the Dashboard size/M size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native Filters: “Clear All” should immediately clear and apply filters without requiring Apply

2 participants