codeant-ai-for-open-source[bot] commented on code in PR #44668:
URL: https://github.com/apache/superset/pull/44668#discussion_r4134518557
##########
superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/index.tsx:
##########
@@ -115,6 +123,16 @@ export default function ControlForm({
[name]: fieldValue,
});
},
+ ...(onReset
+ ? {
+ onReset() {
+ if (onItemReset) {
+ onItemReset();
+ }
+ onReset(name);
+ },
+ }
+ : {}),
Review Comment:
Agreed—this is a real race. Reset should remain immediate, but it must
cancel the pending debounce for that field before deleting the key. Routing
reset through the debounced channel would delay the reset and still risks
ordering issues.
The current debounce map is keyed only by `debounceDelay`, so cancelling it
could also discard unrelated fields using the same delay. Make the debounced
handlers field-specific:
```tsx
const debouncedOnChange = useMemo(
() =>
new Map(
Children.toArray(children)
.flatMap(row => ('children' in row.props ?
Children.toArray(row.props.children) : []))
.map(item => {
const { name, debounceDelay = Constants.FAST_DEBOUNCE } =
item.props;
return [
name,
debounce((fieldValue: JsonValue) => {
onChange({
...value,
[name]: fieldValue,
});
}, debounceDelay),
];
}),
),
[children, onChange, value],
);
```
Then, in the reset wrapper:
```tsx
onReset() {
debouncedOnChange.get(name)?.cancel();
onItemReset?.();
onReset(name);
}
```
The exact construction can be adapted to the existing child traversal, but
the important points are:
1. Keep reset synchronous.
2. Cancel only that field’s pending write.
3. Ensure a delayed toggle cannot re-add the removed key afterward.
A regression test should toggle the checkbox, immediately reset it, advance
timers, and verify that the resettable key remains absent.
--
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]