bito-code-review[bot] commented on code in PR #40470:
URL: https://github.com/apache/superset/pull/40470#discussion_r3347764509
##########
superset-frontend/src/dataMask/reducer.ts:
##########
@@ -109,10 +109,50 @@ function fillNativeFilters(
) {
filterConfig.forEach((filter: Filter) => {
const dataMask = initialDataMask || {};
+ const loaded = dataMask[filter.id];
+
+ // The shallow spread of `loaded` would override `filter.defaultDataMask`
+ // even when the loaded mask is incomplete (e.g. a permalink captured
+ // mid-initialization), wiping out a valid default. For REQUIRED filters
+ // with a default, fall back to the default when the loaded mask carries
+ // no real value OR is missing the extraFormData needed to filter charts.
+ // Non-required filters keep current behavior so a user's explicit clear
+ // isn't undone.
+ const isRequired = !!filter.controlValues?.enableEmptyFilter;
+ const loadedValue = loaded?.filterState?.value;
+ const loadedHasValue =
+ loadedValue !== undefined &&
+ loadedValue !== null &&
+ !(
+ // Treat all-null arrays (range filters use [null, null] as their
+ // canonical cleared value) and empty arrays as "no value".
+ (Array.isArray(loadedValue) && loadedValue.every(v => v === null))
Review Comment:
<!-- Bito Reply -->
The assessment that the `length === 0` check is redundant is correct, as an
empty array will satisfy the `every` condition vacuously. Given that re-adding
the check would trigger a linting error in the CI, it is appropriate to omit
the suggestion.
**superset-frontend/src/dataMask/reducer.ts**
```
// Treat all-null arrays (range filters use [null, null] as their
// canonical cleared value) and empty arrays as "no value".
(Array.isArray(loadedValue) && loadedValue.every(v => v === null))
```
--
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]