You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/15 16:04:07 UTC

[GitHub] [superset] eschutho commented on a diff in pull request #19288: fix: AlertReportCronScheduler tests

eschutho commented on code in PR #19288:
URL: https://github.com/apache/superset/pull/19288#discussion_r851351265


##########
superset-frontend/src/views/CRUD/alert/components/AlertReportCronScheduler.tsx:
##########
@@ -16,44 +16,59 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React, { useState, useCallback, useRef, FunctionComponent } from 'react';
+import React, { useState, useCallback, useRef, FocusEvent } from 'react';
 import { t, useTheme } from '@superset-ui/core';
 
-import { AntdInput } from 'src/components';
+import { AntdInput, RadioChangeEvent } from 'src/components';
 import { Input } from 'src/components/Input';
 import { Radio } from 'src/components/Radio';
 import { CronPicker, CronError } from 'src/components/CronPicker';
 import { StyledInputContainer } from 'src/views/CRUD/alert/AlertReportModal';
 
-interface AlertReportCronSchedulerProps {
+export interface AlertReportCronSchedulerProps {
   value: string;
   onChange: (change: string) => any;
 }
 
-export const AlertReportCronScheduler: FunctionComponent<AlertReportCronSchedulerProps> =
+export const AlertReportCronScheduler: React.FC<AlertReportCronSchedulerProps> =
   ({ value, onChange }) => {
     const theme = useTheme();
     const inputRef = useRef<AntdInput>(null);
     const [scheduleFormat, setScheduleFormat] = useState<'picker' | 'input'>(
       'picker',
     );
+
+    const handleRadioButtonChange = useCallback(
+      (e: RadioChangeEvent) => setScheduleFormat(e.target.value),
+      [],
+    );
+
     const customSetValue = useCallback(
       (newValue: string) => {
         onChange(newValue);
         inputRef.current?.setValue(newValue);
       },
       [inputRef, onChange],
     );
+
+    const handleBlur = useCallback(
+      (event: FocusEvent<HTMLInputElement>) => {
+        onChange(event.target.value);
+      },
+      [onChange],
+    );
+
+    const handlePressEnter = useCallback(() => {
+      onChange(inputRef.current?.input.value || '');
+    }, [onChange]);

Review Comment:
   @diegomedina248 do you think we need `useCallback` for simple Input component props?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org