geido opened a new pull request, #40470:
URL: https://github.com/apache/superset/pull/40470
### SUMMARY
Fixes a regression where required filters with default values intermittently
fail to apply on dashboard load, and the **Apply Filters** button becomes
unresponsive even after the user manually enters a value.
**Customer impact**: MoonActive — charts render unfiltered (potentially
expensive queries) with no way to recover other than refreshing the page.
**Three independent code paths that produce overlapping symptoms — fixed all
three:**
1. **`FilterBar/utils.ts:checkIsApplyDisabled`** — regression from #37681.
The early-return `if (selectedCount !== appliedCount) return true` disabled
Apply whenever Selected had an entry Applied lacked. That is exactly what
happens when a user types a value into a filter whose default never made it
into Applied. Removed the early return; `dataEqual` with `ignoreUndefined:
true` already handles the "no real change" case correctly via lodash `omitBy(v
=> v === undefined)`.
2. **`dataMask/reducer.ts:updateDataMaskForFilterChanges`** — when a
required filter (`enableEmptyFilter=true` or `defaultToFirstItem=true`) was
modified, the existing `filterState`/`extraFormData` was preserved even when
empty, silently wiping a newly defined default. Added a `hasExistingValue`
guard so empty state cannot override a real default. Matches the customer's
"easier to reproduce after modifying required filter configurations" cue.
3. **`dataMask/reducer.ts:fillNativeFilters`** — on `HYDRATE_DASHBOARD`, the
shallow spread of the permalink-loaded `dataMask` over `filter.defaultDataMask`
wiped the default when the loaded mask was captured mid-initialization (e.g.
permalink generated before filters fully populated). Now, **for required
filters only**, we restore `filterState`/`extraFormData` from `defaultDataMask`
when the loaded mask carries no real value. Non-required filters keep current
behavior so an explicit user-clear isn't undone.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — internal state behavior. Reported pattern from the customer:
- Required filter loads empty (or value visible but charts unfiltered).
- User types a value → **Apply Filters** stays disabled.
- After this fix, both paths are corrected.
### TESTING INSTRUCTIONS
Existing unit + integration tests pass (58 tests across `utils.test.ts`,
`reducer.test.ts`, `FilterBar.test.tsx`). One test that locked in the buggy
"count mismatch disables Apply" behavior was updated to assert the corrected
behavior.
**Manual repro (recommended, since the bug is timing-sensitive)**:
1. Open the **Sales dashboard** in Examples.
2. Configure a filter with both **Filter value is required** and **Filter
has default value** enabled.
3. Reload the dashboard a few times. Confirm:
- Default value is pre-filled.
- Charts render filtered (no unfiltered queries).
4. Click into a chart, then navigate back to the dashboard. Repeat step 3 —
defaults must survive the permalink rehydration.
5. Modify the filter configuration (change default, save). Confirm the new
default appears and applies.
6. In a scenario where the default was missing (pre-fix), type a value
manually. Confirm **Apply Filters** becomes enabled.
**Test plan** (CI):
- [ ] `npm run test` in `superset-frontend` — all FilterBar / dataMask
suites green.
- [ ] Manual QA on a test env walking through the steps above.
- [ ] Confirm no regression in Clear All behavior (`FilterBar.test.tsx`
covers this — 21/21 pass).
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
**Open items / caveats**:
- Symptom (b) — "default present in UI but not applied to charts" — is
partly governed by the `needsAutoApply` logic in `FilterBar/index.tsx:237-253`
(untouched). My three fixes target three distinct root causes; if a fourth
remains, it would manifest here. Manual QA on the test env will confirm.
- New regression tests for each fix path (modify-config preserves default,
permalink rehydration preserves default) are deferred per the original
direction — happy to add after manual QA validates the fix shape.
--
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]