Skip to content

Commit b2603f6

Browse files
fix: habia un problema la hacer scroll en mobile. se abria el drawer
1 parent 430c534 commit b2603f6

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

client/src/features/tasks/hooks/task/useTaskHandlers.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useTaskState } from './useTaskState';
44
import { useParams } from 'react-router';
55
import { useModalStore } from '@/features/tasks/store/modalStore';
66
import { ChangeEvent, useCallback } from 'react';
7-
import { MAX_TIMEOUT } from '@/shared/constants/base';
7+
import { MAX_TIMEOUT, SIZE_ID } from '@/shared/constants/base';
88
import { getAIDescription } from '@/shared/services/aiService';
99
import { calculateHeight, resetHeight } from '@/features/tasks/utils/calculateHeight';
1010
import { replaceEmojis } from '@/shared/utils/replaceEmojis';
@@ -13,7 +13,6 @@ import { useUpdateNotifications } from '../../../../shared/hooks/useNotification
1313
import { createNotification } from '@/shared/utils/createNotification';
1414
import { useUpdateTask, useDeleteTask, useDuplicateTask, useMoveTask } from '../useTasks';
1515
import { nanoid } from 'nanoid';
16-
import { SIZE_ID } from '@/shared/constants/base';
1716

1817
// Hook para manejar los handlers de la tarea
1918
export 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

client/src/features/tasks/hooks/task/useTaskState.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const useTaskState = (task: TaskProps) => {
1313
const [isFocused, setIsFocused] = useState(false);
1414
const [previousName, setPreviousName] = useState(task.name);
1515
const [touchStartTime, setTouchStartTime] = useState<number>(0);
16+
const [touchStartY, setTouchStartY] = useState<number>(0);
1617
const [isGeneratingAI, setIsGeneratingAI] = useState(false);
1718
// Estados derivados
1819
const deferredTaskName = useDeferredValue(taskName);
@@ -34,6 +35,8 @@ export const useTaskState = (task: TaskProps) => {
3435
setPreviousName,
3536
touchStartTime,
3637
setTouchStartTime,
38+
touchStartY,
39+
setTouchStartY,
3740
isGeneratingAI,
3841
setIsGeneratingAI,
3942
deferredTaskName,

0 commit comments

Comments
 (0)