sadpandajoe commented on code in PR #44982:
URL: https://github.com/apache/superset/pull/44982#discussion_r4240925766


##########
superset-frontend/src/dashboard/components/RefreshFrequency/RefreshFrequencySelect.tsx:
##########
@@ -100,24 +166,48 @@ export const RefreshFrequencySelect = ({
   value,
   onChange,
 }: RefreshFrequencySelectProps) => {
+  const configuredIntervals = useSelector(
+    (state: RootState) =>
+      // The select also mounts from the Dashboard List / Home pages, where no
+      // dashboard has been hydrated yet; the bootstrapped store carries the
+      // same config there.
+      state.dashboardInfo?.common?.conf?.DASHBOARD_AUTO_REFRESH_INTERVALS ??
+      state.common?.conf?.DASHBOARD_AUTO_REFRESH_INTERVALS,
+  );
+  const options = useMemo(
+    () => getRefreshFrequencyOptions(configuredIntervals),
+    [configuredIntervals],
+  );
+  const presets = options.filter(
+    option => option.value !== CUSTOM_REFRESH_FREQUENCY,
+  );
+
   // Separate radio selection state from value state
   const [radioSelection, setRadioSelection] = useState(() =>
-    isPresetValue(value) ? value : -1,
+    isPresetValue(value, options) ? value : CUSTOM_REFRESH_FREQUENCY,
   );
 
-  const [customValue, setCustomValue] = useState(() => getCustomValue(value));
+  const [customValue, setCustomValue] = useState(() =>
+    getCustomValue(value, options),
+  );
 
   useEffect(() => {
-    const selection = isPresetValue(value) ? value : -1;
+    const selection = isPresetValue(value, options)
+      ? value
+      : CUSTOM_REFRESH_FREQUENCY;
     setRadioSelection(selection);

Review Comment:
   If an operator's DASHBOARD_AUTO_REFRESH_INTERVALS includes `1` (e.g. `[1, "1 
second"]`), clicking **Custom** from another preset calls `onChange(1)` (the 
minimum fallback in `handleRadioChange`). The parent then passes `value = 1`, 
this effect sees `1` as a configured preset, re-selects that radio, clears the 
custom text and disables the input — so the first Custom click lands on a 
1-second refresh instead of opening custom entry. Should the effect keep Custom 
selected when the change originated from the Custom radio/input, rather than 
inferring it only from preset membership?



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