bito-code-review[bot] commented on code in PR #37260:
URL: https://github.com/apache/superset/pull/37260#discussion_r2793381551
##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx:
##########
@@ -416,11 +416,19 @@ const FilterBar: FC<FiltersBarProps> = ({
const handleClearAll = useCallback(() => {
const newClearAllTriggers = { ...clearAllTriggers };
nativeFilterValues.forEach(filter => {
- const { id } = filter;
+ const { id, filterType } = filter;
+ // Range filters use [null, null] as the cleared value; others use
undefined
+ const clearedValue =
+ filterType === 'filter_range' ? [null, null] : undefined;
+ const clearedDataMask = {
+ filterState: { value: clearedValue },
+ extraFormData: {},
+ };
if (dataMaskSelected[id]) {
+ dispatch(updateDataMask(id, clearedDataMask));
setDataMaskSelected(draft => {
if (draft[id].filterState?.value !== undefined) {
- draft[id].filterState!.value = undefined;
+ draft[id].filterState!.value = clearedValue;
}
draft[id].extraFormData = {};
});
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Logic Bug in Filter Clearing</b></div>
<div id="fix">
The conditional check prevents setting the cleared value when the current
filter state value is undefined, which can leave range filters in an incorrect
undefined state instead of [null, null]. This creates inconsistency between the
dispatched data mask and the local state.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
setDataMaskSelected(draft => {
draft[id].filterState!.value = clearedValue;
draft[id].extraFormData = {};
});
````
</div>
</details>
</div>
<small><i>Code Review Run #a16557</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]