From 102ef5b299f53d25bf7bd5222eed67fbe895ab9c Mon Sep 17 00:00:00 2001 From: Balaji Sridharan Date: Mon, 18 Dec 2023 12:22:09 +0530 Subject: [PATCH] feature: Make the calendar icon of the calendar clickable Make the calendar icon clickable that helps to toggle the open status of the calendar. Added new test cases to validate the new feature and updated the existing test case of checking the calendar icon class to make the new feature. Closes #4091 --- src/calendar_icon.jsx | 5 ++++- src/index.jsx | 42 +++++++++++++++++++++++------------- test/calendar_icon.test.js | 31 ++++++++++++++++++++++++++ test/datepicker_test.test.js | 34 ++++++++++++++++++++++++++++- 4 files changed, 95 insertions(+), 17 deletions(-) diff --git a/src/calendar_icon.jsx b/src/calendar_icon.jsx index 20961ce27..8583c8367 100644 --- a/src/calendar_icon.jsx +++ b/src/calendar_icon.jsx @@ -1,7 +1,7 @@ import React from "react"; import PropTypes from "prop-types"; -const CalendarIcon = ({ icon, className = "" }) => { +const CalendarIcon = ({ icon, className = "", onClick }) => { const defaultClass = "react-datepicker__calendar-icon"; if (React.isValidElement(icon)) { @@ -15,6 +15,7 @@ const CalendarIcon = ({ icon, className = "" }) => {