File tree Expand file tree Collapse file tree 4 files changed +9
-22
lines changed Expand file tree Collapse file tree 4 files changed +9
-22
lines changed Original file line number Diff line number Diff line change @@ -67,17 +67,6 @@ describe('useInputDate Hook', () => {
67
67
} ) ;
68
68
expect ( onChange ) . toHaveBeenCalledTimes ( 1 ) ;
69
69
} ) ;
70
- it ( 'handleShowCalendar - call onCalendarOpen' , ( ) => {
71
- const onCalendarOpen = jest . fn ( ) ;
72
- const format = 'DD-MM-YYYY' ;
73
- const minDate = new Date ( '01-01-2000' ) ;
74
- const { result } = renderHookProvider ( ( ) => useInputDate ( { format, minDate, onCalendarOpen } ) ) ;
75
-
76
- act ( ( ) => {
77
- result . current . handleShowCalendar ( ) ;
78
- } ) ;
79
- expect ( onCalendarOpen ) . toHaveBeenCalledTimes ( 1 ) ;
80
- } ) ;
81
70
it ( 'handleChangeInternalValidate with range value- call onChange' , ( ) => {
82
71
const onChange = jest . fn ( ) ;
83
72
const format = 'DD-MM-YYYY' ;
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ type ReturnType = ReturnTypeInputHook & {
44
44
// functions
45
45
handleClickInput : React . MouseEventHandler < HTMLInputElement > ;
46
46
handlePickCalendarDate : ( newDate : Date [ ] ) => void ;
47
- handleShowCalendar : ( ) => void ;
48
47
handleOpenCalendar : ( open : boolean ) => void ;
49
48
handleChangeInternalValidate : ChangeEventHandler < HTMLInputElement > ;
50
49
handleWrapperBlur : FocusEventHandler < HTMLDivElement > ;
@@ -229,12 +228,6 @@ export const useInputDate = ({
229
228
) ;
230
229
231
230
// Methods
232
- // Click on the icon to show the calendar
233
- const handleShowCalendar = ( ) => {
234
- setCalendarOpen ( ! calendarOpen ) ;
235
- props . onCalendarOpen ?.( ! calendarOpen ) ;
236
- } ;
237
-
238
231
// Popover control calendar
239
232
const handleOpenCalendar = ( open : boolean ) : void => {
240
233
setCalendarOpen ( open ) ;
@@ -509,7 +502,6 @@ export const useInputDate = ({
509
502
calendarOpen,
510
503
handleClickInput,
511
504
handlePickCalendarDate,
512
- handleShowCalendar,
513
505
handleOpenCalendar,
514
506
handleChangeInternalValidate,
515
507
value,
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ const InputDateComponent = React.forwardRef(
65
65
calendarOpen,
66
66
handleClickInput,
67
67
handlePickCalendarDate,
68
- handleShowCalendar,
69
68
handleOpenCalendar,
70
69
value,
71
70
state,
@@ -122,7 +121,13 @@ const InputDateComponent = React.forwardRef(
122
121
calendarOpen = { calendarOpen }
123
122
dateFormatted = { dateFormatted }
124
123
hasRange = { hasRange }
125
- icon = { { ...props . icon , onClick : handleShowCalendar } }
124
+ icon = { {
125
+ ...props . icon ,
126
+ onClick : event => {
127
+ handleOpenCalendar ( ! calendarOpen ) ;
128
+ props . icon ?. onClick ?.( event ) ;
129
+ } ,
130
+ } }
126
131
informationAssociatedValue = { informationAssociatedValue }
127
132
mask = { mask }
128
133
maskType = { maskType }
@@ -136,7 +141,7 @@ const InputDateComponent = React.forwardRef(
136
141
rightIcon = { {
137
142
...props . rightIcon ,
138
143
onClick : event => {
139
- handleShowCalendar ( ) ;
144
+ handleOpenCalendar ( ! calendarOpen ) ;
140
145
props . rightIcon ?. onClick ?.( event ) ;
141
146
} ,
142
147
} }
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ export const InputDateStandAloneComponent = (
44
44
variant = { props . inputVariant ?? props . styles ?. [ props . state ] ?. inputVariant }
45
45
/>
46
46
< PopoverCalendar
47
+ ref = { ref }
47
48
calendar = { props . calendar }
48
49
calendarOpen = { props . calendarOpen }
49
50
closeIcon = { props . closeIcon }
You can’t perform that action at this time.
0 commit comments