@@ -268,6 +268,7 @@ let CalendarBasicComp = (function () {
268
268
const ref = createRef < HTMLDivElement > ( ) ;
269
269
const editEvent = useRef < EventInput > ( ) ;
270
270
const initData = useRef < boolean > ( false ) ;
271
+ const clickTimeout = useRef < NodeJS . Timeout | null > ( null ) ;
271
272
const [ form ] = Form . useForm ( ) ;
272
273
const [ left , setLeft ] = useState < number | undefined > ( undefined ) ;
273
274
const [ licensed , setLicensed ] = useState < boolean > ( props . licenseKey !== "" ) ;
@@ -370,6 +371,15 @@ let CalendarBasicComp = (function () {
370
371
initData . current = true ;
371
372
}
372
373
} , [ JSON . stringify ( initialEvents ) , comp ?. children ?. comp ?. children ?. initialData ] ) ;
374
+
375
+ // Cleanup timeout on unmount
376
+ useEffect ( ( ) => {
377
+ return ( ) => {
378
+ if ( clickTimeout . current ) {
379
+ clearTimeout ( clickTimeout . current ) ;
380
+ }
381
+ } ;
382
+ } , [ ] ) ;
373
383
374
384
const resources = useMemo ( ( ) => props . resources . value , [ props . resources . value ] ) ;
375
385
@@ -850,22 +860,30 @@ let CalendarBasicComp = (function () {
850
860
handleEventDataChange ,
851
861
] ) ;
852
862
863
+ const handleSingleClick = useCallback ( ( ) => {
864
+ // Prevent double click from triggering the event
865
+ // Use a timeout to debounce rapid clicks
866
+ if ( clickTimeout . current ) {
867
+ clearTimeout ( clickTimeout . current ) ;
868
+ clickTimeout . current = null ;
869
+ return ; // This was a double click, don't trigger
870
+ }
871
+
872
+ clickTimeout . current = setTimeout ( ( ) => {
873
+ props . onEvent ( 'click' ) ;
874
+ clickTimeout . current = null ;
875
+ } , 150 ) ; // Small delay to catch double clicks
876
+ } , [ props . onEvent ] ) ;
877
+
853
878
const handleDbClick = useCallback ( ( ) => {
854
- const event = props . updatedEventsData . find (
855
- ( item : EventType ) => item . id === editEvent . current ?. id
856
- ) as EventType ;
857
879
if ( ! props . editable || ! editEvent . current ) {
858
880
return ;
859
881
}
860
- if ( event ) {
861
- showModal ( event , true ) ;
882
+ if ( onEventVal && onEventVal . some ( ( e : any ) => e . name === 'doubleClick' ) ) {
883
+ // Check if 'doubleClick' is included in the array
884
+ props . onEvent ( 'doubleClick' ) ;
862
885
} else {
863
- if ( onEventVal && onEventVal . some ( ( e : any ) => e . name === 'doubleClick' ) ) {
864
- // Check if 'doubleClick' is included in the array
865
- props . onEvent ( 'doubleClick' ) ;
866
- } else {
867
- showModal ( editEvent . current as EventType , false ) ;
868
- }
886
+ showModal ( editEvent . current as EventType , false ) ;
869
887
}
870
888
} , [
871
889
editEvent ,
@@ -974,6 +992,9 @@ let CalendarBasicComp = (function () {
974
992
allDaySlot = { props . showAllDay }
975
993
eventContent = { renderEventContent }
976
994
select = { ( info ) => handleCreate ( info ) }
995
+ dateClick = { ( ) => {
996
+ handleSingleClick ( ) ;
997
+ } }
977
998
eventClick = { ( info ) => {
978
999
const event = events . find (
979
1000
( item : EventInput ) => item . id === info . event . id
@@ -982,6 +1003,7 @@ let CalendarBasicComp = (function () {
982
1003
setTimeout ( ( ) => {
983
1004
editEvent . current = undefined ;
984
1005
} , 500 ) ;
1006
+ handleSingleClick ( ) ;
985
1007
} }
986
1008
moreLinkClick = { ( info ) => {
987
1009
let left = 0 ;
0 commit comments