Repository navigation
Conversation
…-level setting The Customize columns popover wrote every checkbox change as an explicit value, so once a key like showCellBars landed in column_config there was no way to drop the override and follow the chart-level option again. Mark the props that mirror a chart-level option (showCellBars, alignPositiveNegative, colorPositiveNegative) as resettable and offer a reset action that deletes the key, restoring the inheritance the chart consumers already implement.
| ...(onReset | ||
| ? { | ||
| onReset() { | ||
| if (onItemReset) { | ||
| onItemReset(); | ||
| } | ||
| onReset(name); | ||
| }, | ||
| } | ||
| : {}), |
There was a problem hiding this comment.
Suggestion: A pending debounced field change can run after reset and re-add the removed key from the stale form value, undoing the reset.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Race condition
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/index.tsx
**Line:** 126:135
**Comment:**
*Race Condition: A pending debounced field change can run after reset and re-add the removed key from the stale form value, undoing the reset.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Agreed—confirmed by reproducing it: toggle a resettable checkbox (starting the ~200ms debounce), then click "Use the chart-level setting" before it fires. The reset removes the key immediately, but the already-scheduled write still lands afterward with the stale pre-reset value and silently re-adds the key. Should the reset path cancel or flush any pending debounced write for that field first, or route resets through the same debounced channel as toggles?
There was a problem hiding this 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:
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:
onReset() {
debouncedOnChange.get(name)?.cancel();
onItemReset?.();
onReset(name);
}The exact construction can be adapted to the existing child traversal, but the important points are:
- Keep reset synchronous.
- Cancel only that field’s pending write.
- 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.
|
The flagged issue is correct. Because To resolve this, you should cancel any pending debounced updates when Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well? superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx |
| const [value, setValue] = useState( | ||
| initialValue === undefined ? defaultValue : initialValue, | ||
| ); | ||
| const [prevInitialValue, setPrevInitialValue] = useState(initialValue); | ||
| if (initialValue !== prevInitialValue) { | ||
| // the parent value changed outside this item (e.g. the reset action | ||
| // removed the key) — follow it instead of keeping the stale local state | ||
| setPrevInitialValue(initialValue); | ||
| setValue(initialValue === undefined ? defaultValue : initialValue); | ||
| } |
There was a problem hiding this comment.
Suggestion: After reset, the checkbox falls back to the item default instead of the actual chart-level value, so it can display the wrong effective setting.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Api mismatch
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx
**Line:** 63:72
**Comment:**
*Api Mismatch: After reset, the checkbox falls back to the item default instead of the actual chart-level value, so it can display the wrong effective setting.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Agreed—after a reset, the checkbox's local value falls back to the item spec's static defaultValue (e.g. true for showCellBars), not the actual current chart-level setting, since that value is never passed into this component. If the chart-level option differs from the spec default, the checkbox can show the wrong effective state right after reset. Could the popover pass the resolved chart-level value down as the fallback instead of the static per-field default?
| type="link" | ||
| size="small" | ||
| css={{ padding: 0, height: 'auto', fontSize: fontSizeXS }} | ||
| onClick={onReset} |
There was a problem hiding this comment.
Suggestion: Clicking reset soon after changing the checkbox can let the pending debounced update run afterward and recreate the removed per-column override.
Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx
**Line:** 137:137
**Comment:**
*Race Condition: Clicking reset soon after changing the checkbox can let the pending debounced update run afterward and recreate the removed per-column override.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #44668 +/- ##
=======================================
Coverage 85.66% 85.67%
=======================================
Files 3111 3111
Lines 214938 214956 +18
Branches 50908 50917 +9
=======================================
+ Hits 184136 184161 +25
+ Misses 27381 27379 -2
+ Partials 3421 3416 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review Agent Run #bcf0b3
Actionable Suggestions - 1
-
superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigPopover.tsx - 1
- Duplicated onReset handler · Line 84-90
Additional Suggestions - 3
-
superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigPopover.tsx - 1
-
Reset races debounced onChange · Line 85-89This reset handler races the debounced `onChange` in `ControlForm` (index.tsx:84, 115-124): the debounced commit re-spreads the render-time `value` (`{...value, [name]: fieldValue}`), so a reset fired within the debounce window is overwritten by the pending edit and the key reappears. Consider cancelling/flushing the pending debounce before reset.
-
-
superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx - 1
-
Duplicated inline type intersection · Line 117-119The inline intersection `& { resettable: true; }` is repeated verbatim on `showCellBars`, `alignPositiveNegative`, and `colorPositiveNegative`. A single local alias (e.g. `ResettableCheckboxSpec`) would keep the three declarations in sync. The optional marker already exists as `ControlFormItemDefaultSpec` in `types.ts`, but importing it here would cycle, since `types.ts` imports from `./constants` — hence a local alias.
-
-
superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/index.tsx - 1
-
Reset hook ordering fragile · Line 126-135The injected `onReset` runs `onItemReset()` before `onReset(name)`. `onItemReset` is `ControlFormItem`'s `onReset` prop, whose only current use is the reset-button `onClick` (`ControlFormItem.tsx:137`) — it performs no state reset itself. If a future item uses it to clear local state, running it before the parent removes the key means the item re-syncs from the stale pre-reset `value` prop (`ControlFormItem.tsx:67-72`), reintroducing the override. Ordering the parent reset first is the safer contract.
-
Review Details
-
Files reviewed - 6 · Commit Range:
6491503..6491503- superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigPopover.tsx
- superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlForm.reset.test.tsx
- superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/ControlFormItem.tsx
- superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/index.tsx
- superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
- superset-frontend/src/explore/components/controls/ColumnConfigControl/types.ts
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Eslint (Linter) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers an incremental AI Review. -
/review full- Manually triggers a full AI Review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
| onReset={name => | ||
| onChange( | ||
| Object.fromEntries( | ||
| Object.entries(column.config).filter(([key]) => key !== name), | ||
| ), | ||
| ) | ||
| } |
There was a problem hiding this comment.
The onReset handler added at lines 84-90 and lines 106-112 is character-identical in both the tabbed and non-tab ControlForm branches. Extract it once (e.g. handleReset) so a future change to the reset semantics cannot diverge between the two branches.
Code Review Run #bcf0b3
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
There was a problem hiding this comment.
Agreed—both ControlForm call sites in this file implement the exact same key-deletion closure. Since ControlForm already owns the value and calls onChange with the full object on every change, would it make more sense for the onReset channel to delete the key internally and call onChange itself, rather than requiring every caller to reimplement the same filter?
There was a problem hiding this comment.
Moving the key-deletion logic into ControlForm is a sound architectural improvement. It centralizes the reset semantics, reduces code duplication across call sites, and ensures consistent behavior, which aligns with the reviewer's goal of preventing divergence in reset logic. Since ControlForm already manages the onChange callback and the value state, it is well-positioned to handle the key removal internally.
superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigPopover.tsx
<ControlForm
onChange={onChange}
onReset={name => {
const { [name]: _, ...rest } = column.config;
onChange(rest);
}}
/>
| * action that deletes the key from column_config so the column follows | ||
| * the chart-level setting again. | ||
| */ | ||
| resettable?: boolean; |
There was a problem hiding this comment.
resettable is typed generically on ControlFormItemDefaultSpec, so any control spec can set resettable: true, but only the Checkbox branch in ControlFormItem ever reads it. A resettable non-checkbox field would compile cleanly and silently render no reset action. Would it be worth scoping the type to checkbox specs, or wiring the reset UI for other control types too?
| label="Show cell bars" | ||
| description="Whether to display a bar chart background in table columns" | ||
| defaultValue | ||
| debounceDelay={0} |
There was a problem hiding this comment.
Every test in this file passes debounceDelay={0}, which routes through ControlForm's synchronous 0 bucket and never exercises lodash.debounce. The three resettable checkboxes use a real 200ms delay in production, so this suite can't catch a regression where a pending debounced write fires after a reset and re-adds the key it just removed. Could you add a case using the production 200ms delay with fake timers — toggle, reset within the window, advance the timer, and assert the key is still gone?
| css={{ padding: 0, height: 'auto', fontSize: fontSizeXS }} | ||
| onClick={onReset} | ||
| > | ||
| <Icons.RollbackOutlined iconSize="s" />{' '} |
There was a problem hiding this comment.
Icons.RollbackOutlined carries an implicit, untranslated label, so a screen reader may announce something like "rollback Use the chart-level setting" instead of just the translated action text. Could the icon be marked decorative (e.g. aria-hidden) so the button's text alone supplies its accessible name?
| validationErrors={validationErrors} | ||
| {...props} | ||
| /> | ||
| {hasOverride && onReset && ( |
There was a problem hiding this comment.
Clicking reset removes the per-column override, which flips hasOverride to false and unmounts this button on the next render — a keyboard user who just activated it loses focus to the document instead of staying inside the popover. Could focus move to the checkbox (or another stable element) right after reset instead of being dropped?
The reset control's label was added as a new translatable string, so the extraction template fell one entry behind source and the job that guards the template failed the PR. The entry is a plain label with no format specifiers and no rename behind it, so no catalog loses a translation: every language sits at translated +0, fuzzy +0 against the base branch.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| screen.getByRole('button', { name: /use the chart-level setting/i }), | ||
| ); | ||
| expect(onReset).toHaveBeenCalledWith('showCellBars'); | ||
| // the key must be gone from the propagated value, not set to true/false |
There was a problem hiding this comment.
This deletion test passes even if the popover never removes the override: onReset is a no-op mock and onChange is never called. Could it exercise ColumnConfigPopover with { showCellBars: false, d3NumberFormat: ".2f" } and assert that resetting emits { d3NumberFormat: ".2f" }, preserving the unrelated setting while removing the override?
The reset test drove ControlForm with a mocked onReset, so it stayed green even if the popover's filter never removed anything — the deletion lives one level up, and nothing exercised it. Rendering the popover instead pins the behaviour that matters: the reset key is gone from the emitted value while an unrelated formatting override on the same column survives.
Code Review Agent Run #c7864eActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
| <ControlForm onChange={onChange} value={column.config}> | ||
| <ControlForm | ||
| onChange={onChange} | ||
| onReset={name => |
There was a problem hiding this comment.
Resetting an override rebuilds the config from the committed column.config, so it ignores edits ControlForm is still holding in its debounce buffer. If someone changes Min width from 100 to 120 and clicks "Use the chart-level setting" within the debounce window, this emits width 100, the resulting prop update cancels the pending write, and the input can still show 120 while 100 is what gets saved (same closure again at line 106). Should the key deletion live in ControlForm, starting from its latest pending value, so unrelated pending edits survive and the two call sites share one implementation?
| const onChange = jest.fn(); | ||
| render( | ||
| <ColumnConfigPopover | ||
| column={{ |
There was a problem hiding this comment.
ColumnConfigInfo requires a key (types.ts), and this column fixture omits it, so the frontend type-check will report a missing property for this test file. Should this add key: 'my_column'?
| screen.getByRole('button', { name: /use the chart-level setting/i }), | ||
| ); | ||
| // the override is gone, the unrelated formatting override survives | ||
| expect(onChange).toHaveBeenCalledWith({ d3NumberFormat: '.2f' }); |
There was a problem hiding this comment.
toHaveBeenCalledWith treats an undefined-valued property as equal to a missing one, so this still passes if the popover emits { d3NumberFormat: '.2f', showCellBars: undefined } instead of deleting the key, and the point of the PR is that the key is gone. Could this inspect onChange.mock.calls[0][0] and assert not.toHaveProperty('showCellBars') (or use toStrictEqual)?
|
Thanks @kokhlo, the approach fits #44667. A few things are still open before this can go in. The reset can be undone by a pending debounced write: toggle a checkbox, click reset inside the ~200ms window, and the stale write puts the key back. Reset needs to cancel that field's pending debounce first. The I'll see if I can help push it forward, if that's cool. |
Summary
Fixes #44667.
Root cause:
ControlFormpropagated every checkbox change as an explicit value —onChange({ ...value, [name]: fieldValue })— so once a key likeshowCellBarslanded incolumn_configno code path could remove it.ControlFormItemalso seeded the checkbox from the item spec's owndefaultValue, which made an untouched column render exactly like an explicit override. The chart consumers already implement the inheritance (e.g.TableChart.tsxresolvesconfig.showCellBars === undefined ? showCellBars : config.showCellBars; AG Grid'suseColDefs.tsdoes the same), so the gap was purely in the control layer.Fix, scoped to the props that mirror a chart-level option (
showCellBars,alignPositiveNegative,colorPositiveNegative):resettable: true;column_config(via a new optionalonResetchannel onControlForm) instead of writing another explicit value, so the column follows the chart-level option again — including when that option flips later;visible,columnWidth, formats) are untouched, and consumers that don't passonResetsee no UI change.Testing
jest src/explore/components/controls/ColumnConfigControl→ 2 suites, 7 passed (4 new tests: reset action visible only for an explicit override; reset deletes the key rather than writing a value; toggling still writes an explicit value;resettableset on exactly the three chart-mirrored props).ControlFormItem(Zoom/MapView/LayerConfigs controls) → 10 passed, no regressions from the new optional prop.scripts/oxfmt.shapplied;oxlint --config oxlint.jsonclean on the touched directory.master(10ca640).