@@ -4,7 +4,7 @@ import { useTaskState } from './useTaskState';
44import { useParams } from 'react-router' ;
55import { useModalStore } from '@/features/tasks/store/modalStore' ;
66import { ChangeEvent , useCallback } from 'react' ;
7- import { MAX_TIMEOUT } from '@/shared/constants/base' ;
7+ import { MAX_TIMEOUT , SIZE_ID } from '@/shared/constants/base' ;
88import { getAIDescription } from '@/shared/services/aiService' ;
99import { calculateHeight , resetHeight } from '@/features/tasks/utils/calculateHeight' ;
1010import { replaceEmojis } from '@/shared/utils/replaceEmojis' ;
@@ -13,7 +13,6 @@ import { useUpdateNotifications } from '../../../../shared/hooks/useNotification
1313import { createNotification } from '@/shared/utils/createNotification' ;
1414import { useUpdateTask , useDeleteTask , useDuplicateTask , useMoveTask } from '../useTasks' ;
1515import { nanoid } from 'nanoid' ;
16- import { SIZE_ID } from '@/shared/constants/base' ;
1716
1817// Hook para manejar los handlers de la tarea
1918export const useTaskHandlers = ( task : TaskProps , state : ReturnType < typeof useTaskState > ) => {
@@ -109,21 +108,23 @@ export const useTaskHandlers = (task: TaskProps, state: ReturnType<typeof useTas
109108 setTask ( { ...task , checked : state . checked } ) ;
110109 } , [ task , state . checked , state . isFocused , setIsOpen , setTask ] ) ;
111110
112- // Handler para iniciar el tiempo de pulsación
113- const handleTouchStart = useCallback ( ( ) => {
114- if ( state . isFocused ) return ;
115- state . setTouchStartTime ( Date . now ( ) ) ;
116- } , [ state . isFocused ] ) ;
111+ const handleTouchStart = useCallback (
112+ ( e : React . TouchEvent ) => {
113+ if ( state . isFocused ) return ;
114+ state . setTouchStartTime ( Date . now ( ) ) ;
115+ state . setTouchStartY ( e . touches [ 0 ] . clientY ) ;
116+ } ,
117+ [ state . isFocused ]
118+ ) ;
117119
118- // Handler para abrir la tarea al soltar el dedo (tap corto)
119120 const handleTouchEnd = useCallback (
120121 ( e : React . TouchEvent ) => {
121122 if ( state . isFocused ) return ;
122- e . preventDefault ( ) ;
123123 const touchDuration = Date . now ( ) - state . touchStartTime ;
124- if ( touchDuration < MAX_TIMEOUT ) handleClick ( ) ;
124+ const deltaY = Math . abs ( e . changedTouches [ 0 ] . clientY - state . touchStartY ) ;
125+ if ( touchDuration < MAX_TIMEOUT && deltaY < 10 ) handleClick ( ) ;
125126 } ,
126- [ state . touchStartTime , state . isFocused , handleClick ]
127+ [ state . touchStartTime , state . touchStartY , state . isFocused , handleClick ]
127128 ) ;
128129
129130 // Handler para actualizar el nombre de la tarea cuando se cambia
0 commit comments