yousoph opened a new pull request, #40978:
URL: https://github.com/apache/superset/pull/40978
### SUMMARY
When filters A and B both have **Select first filter value**
(`defaultToFirstItem = true`) enabled and B depends on A, charts received a
partial/incorrect filter set on dashboard load. The user had to click **Apply**
a second time to get the correct result.
**Root cause:** The readiness guard in `FilterValue.tsx` compares
`selectedParentFilterValueCounts` against `depsCount`. On initial load both
values are `0` (A's `extraFormData` is empty — it hasn't auto-selected yet), so
`0 === 0` passes the guard and B fetches options from the unfiltered dataset
immediately. B then auto-selects the first unfiltered item (e.g. `model =
'Acura'`) and, because it is a first-initialization with `requiredFirst = true`
(set by `defaultToFirstItem`), dispatches that value to charts.
When A later auto-selects its first item (e.g. `make = 'Toyota'`), B
re-fetches with Toyota's filter and re-selects the correct first Toyota model.
But by this point B is **no longer** a first-initialization event, so
`shouldDispatch` is `false` in `handleFilterSelectionChange` and the corrected
value is silently dropped. Charts are left with A=Toyota + B=Acura (wrong).
**Fix:** Before the existing count-based check in the readiness guard, add a
short-circuit that returns early when any transitive ancestor with
`defaultToFirstItem = true` has not yet set `filterState.value`. This ensures
B's first fetch and auto-select happen only after A has settled, keeping the
first-initialization dispatch path intact.
Shortcut: sc-108451
Related: #39504 (sc-102912, transitive ancestor chain fix)
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — behavior-only fix, no UI change.
### TESTING INSTRUCTIONS
1. Create a dashboard with the **Vehicle Sales** dataset.
2. Add two native **Value** filters:
- Filter A — column `make`, enable **Select first filter value**
- Filter B — column `model`, enable **Select first filter value**, set
**Parent filter** = A
3. Scope both filters to a chart that uses `make` and `model`.
4. Save, then **reload** the dashboard (do not click Apply).
5. **Before this fix:** the chart is filtered by only one of the two values;
a second Apply is needed.
6. **After this fix:** both filters are auto-applied correctly on the first
load — B shows the first model belonging to A's first make.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]