Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom time input needs 2 clicks to focus #4949

Closed
kmsomebody opened this issue Jul 1, 2024 · 3 comments · Fixed by #5088 · May be fixed by qburst/react-datepicker-3#31
Closed

Custom time input needs 2 clicks to focus #4949

kmsomebody opened this issue Jul 1, 2024 · 3 comments · Fixed by #5088 · May be fixed by qburst/react-datepicker-3#31
Assignees

Comments

@kmsomebody
Copy link

Describe the bug
The time input does not focus when you click on it the first time. It needs 2 clicks to focus.

To Reproduce

  1. Go to the "Custom time input" example.
  2. Click on the datepicker input to open the picker.
  3. Click on the time input.
  4. The time input is not focused.
  5. Click on the time input again.
  6. The time input is focused.

Expected behavior
The time input should be focused the first time you click on it.

Desktop

  • OS: Windows 11
  • Browser: Firefox Developer Edition 128.0b7 and Chrome 126.0.6478.127

Additional context
Upgraded from react-datepicker 4.17.0 to 7.2.0. It was working fine before.

@ezParth
Copy link

ezParth commented Jul 5, 2024

Hi @martijnrusschen,

Please assign this issue to me. I'll work on this.

@ezParth
Copy link

ezParth commented Jul 5, 2024

Hey I have create a pull request, you can out the solution there. Now the input bar is getting toggled in one click @kmsomebody

@balajis-qb
Copy link

balajis-qb commented Sep 13, 2024

When I analyzed this issue, it's not related to the example of the custom time input we use. But also with the default time input.

We can reproduce the double click time input issue mentioned using one of the following code

  1. Default Time Input
() => {
  const [startDate, setStartDate] = useState(new Date());
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      timeInputLabel="Time:"
      dateFormat="MM/dd/yyyy h:mm aa"
      shouldCloseOnSelect={false}
      showTimeInput
    />
  );
};
  1. Custom Time Input
() => {
  const [startDate, setStartDate] = useState(new Date());
  const ExampleCustomInput = forwardRef(
    ({ value, onClick, className }, ref) => (
      <button className={className} onClick={onClick} ref={ref}>
        {value}
      </button>
    ),
  );
  return (
    <DatePicker
      selected={startDate}
      onChange={(date) => setStartDate(date)}
      customInput={<ExampleCustomInput className="example-custom-input" />}
    />
  );
};

@martijnrusschen, can you please assign this issue to me. I fixed the issue, will raise a PR in sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment