sadpandajoe opened a new issue, #44922:
URL: https://github.com/apache/superset/issues/44922
### Bug description
`ControlForm` shares one lodash-debounced `onChange` per delay and builds
each payload as `{ ...value, [name]: fieldValue }` from the `value` prop at
render time. If a second field is edited before the first edit's debounce (250
ms `FAST_DEBOUNCE`) fires and before the parent has re-rendered with the new
`value`, the second call replaces the pending first call and its payload is
built from the stale `value`, so the first field's edit is dropped.
Steps to reproduce: open a column's settings popover (e.g. a table column's
Customize options), type in one text field (e.g. custom column name) and
immediately (<250 ms) change another field (e.g. a toggle/number format). Only
the last field's change is saved; the first reverts.
Expected: both edits are kept (merge into the latest pending value, or flush
the pending call before the next).
### Where
`superset-frontend/src/explore/components/controls/ColumnConfigControl/ControlForm/index.tsx`
- L73-L80 `debouncedOnChange` (one `debounce(onChange, FAST_DEBOUNCE)`
shared by all items)
- L107-L116 per-item handler: `debouncedOnChange[debounceDelay]({ ...value,
[name]: fieldValue })`
### Suggested fix
Keep a ref of the latest pending form value, merge `[name]: fieldValue` into
it on every edit, and debounce a call that sends the merged ref (reset it after
firing).
### Found by
Found while adding React Testing Library coverage for Explore controls (all
line numbers are against `master` at `bc3698b5d6`).
--
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]