YuriyKrasilnikov commented on PR #37790:
URL: https://github.com/apache/superset/pull/37790#issuecomment-3874447639

   ### Update: DeferredInput component
   
   Fixes the input lag that remained in translation fields after the debounce 
fix. The debounce only addressed the lightweight `formChanged()` notification — 
the heavy state update (`setNativeFilterFieldValues`, 
`handleTranslationChange`) still fired synchronously on every keystroke, 
causing the entire parent tree to re-render mid-typing.
   
   **Root cause:** antd `Form.Item` with `name` prop makes inputs uncontrolled 
(fast), but locale-mode translation inputs can't use `name` binding (they write 
to nested JSON, not a flat form field). So they fall back to controlled `value` 
+ `onChange` — and when `onChange` triggers a heavy state update on every 
keystroke, input becomes visibly laggy.
   
   **Solution:** new `DeferredInput` component that decouples typing from state 
propagation. Internally maintains local state for instant keystroke feedback. 
Propagates to parent only on blur or after 300ms debounce. Accepts external 
`value` prop for locale switching and form resets, with `lastPropagatedRef` to 
avoid echo-induced cursor jumps.
   
   Applied to all 4 translation input locations:
   - `FiltersConfigForm` — filter name
   - `MetricLabelTranslations` — adhoc metric label
   - `Chart PropertiesModal` — chart name (split: `Input` for default mode, 
`DeferredInput` for locale mode)
   - `Dashboard BasicInfoSection` — dashboard title
   
   Also moved `LocaleSwitcher` from `AdhocMetricEditPopoverTitle` (popover 
title bar — click conflicts, translations not saving) to popover body via 
dedicated `MetricLabelTranslations` component.
   
   10 unit tests for DeferredInput covering debounce, blur flush, unmount 
flush, external value sync, echo protection, props forwarding. All existing 
tests pass (62 across 4 suites).


-- 
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]

Reply via email to