kokhlo commented on code in PR #44982:
URL: https://github.com/apache/superset/pull/44982#discussion_r4241048341
##########
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:
Confirmed — traced it on the current head: with `1` in the operator config,
the Custom click calls `onChange(MINIMUM_REFRESH_INTERVAL)`, the parent
round-trips `value = 1` back, and the `[value, options]` effect re-derives
selection from preset membership, so the radio snaps to the 1-second preset and
`customValue` is cleared. The inference only holds while no configured preset
collides with the fallback seed.
Agree the selection should not be re-inferred when the change originated
from the Custom control here — will push a follow-up that keeps Custom selected
in that case instead of guessing from 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]