MatanBobi commented on a change in pull request #15147:
URL: https://github.com/apache/superset/pull/15147#discussion_r651598039



##########
File path: 
superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx
##########
@@ -29,12 +29,15 @@ import {
   FrameComponentProps,
 } from '../types';
 
-export function CalendarFrame(props: FrameComponentProps) {
-  let calendarRange = PreviousCalendarWeek;
-  if (CALENDAR_RANGE_SET.has(props.value as CalendarRangeType)) {
-    calendarRange = props.value;
-  } else {
-    props.onChange(calendarRange);
+export function CalendarFrame({ onChange, value }: FrameComponentProps) {
+  useEffect(() => {
+    if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+      onChange(PreviousCalendarWeek);
+    }
+  }, [onChange, value]);
+
+  if (!CALENDAR_RANGE_SET.has(value as CalendarRangeType)) {
+    return null;

Review comment:
       The whole purpose of this PR is to change the "default value" approach 
because it was broken.
   What I'm doing here is if the initial value isn't one of the calendar range 
options, I'm returning `null` so in the next render I'll get the correct value 
and render the proper item.




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

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