Skip to content

Calendar Toggle Utility is not closing the datepicker #6252

@balajis-qb

Description

@balajis-qb

Describe the bug
When we render a DatePicker with toggleCalendarOnIconClick prop, we should be able to toggle the open state of the calendar by clicking on the Calendar Icon. However we can only able to open the calendar using the icon, when we try to close it by reclicking on that icon, it's getting closed. But however it's getting reopened automatically.

To Reproduce
Steps to reproduce the behavior:

  1. Click on the calendar icon. The Datepicker will open
  2. Reclick the calendar icon. Instead of closing the calendar, it'll close and reopen
const ToggleCalendarOnIconClick = () => {
  const [selectedDate, setSelectedDate] = useState<Date | null>(new Date());

  return (
    <DatePicker
      showIcon
      toggleCalendarOnIconClick
      selected={selectedDate}
      onChange={setSelectedDate}
    />
  );
};
React-Datepicker-crafted-by-HackerOne.8.mp4

Expected behavior
As per the prop name toggleCalendarOnIconClick, it should properly toggle the calendar open state.

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions