I'm starting my adventure with react and I have a reusable component of type DateTime like that:
interface IProps
  extends FieldRenderProps<Date, HTMLElement>,
    FormFieldProps {}
const DateInput: React.FC<IProps> = ({
  input,
  width,
  placeholder,
  date = false,
  time = false,
  meta: { touched, error },
  id,
  ...rest
}) => {
  const [isOpen, setIsOpen] = useState<false | "date" | "time" | undefined>(false);
  
  return (
  <Form.Field  error={touched && !!error} width={width}>
      <DateTimePicker 
        onFocus={() => setIsOpen("date")} //here I would like it to be set false or time/date depending on props value
        placeholder={placeholder}
        value={input.value || null}
        onChange={input.onChange}
        date={date}
        time={time}
        {...rest}
        open={isOpen}
      />
      {touched && error && (
          <Label basic color='red'>
              {error}
          </Label>
      )}
  </Form.Field>
  )
};
I would like it to open when I click on the field. Thats why I added that:
const [isOpen, setIsOpen] = useState<false | "date" | "time" | undefined>(false);
Maybe it is not the best way to do that :/
Problem with that code is that when I select input the it is set to open but even if it looses focuse then still it is open. I would like it to be closed after sleecting a date or clicking somewhere else.
And second thing is that I would like it to open date/time depending on props set on component (date = false; time = false)
Could you please help me with that task?
 
     
    