diff --git a/worklenz-frontend/src/components/task-list-v2/TaskListV2.tsx b/worklenz-frontend/src/components/task-list-v2/TaskListV2.tsx index 6c89515c..37af547a 100644 --- a/worklenz-frontend/src/components/task-list-v2/TaskListV2.tsx +++ b/worklenz-frontend/src/components/task-list-v2/TaskListV2.tsx @@ -283,6 +283,24 @@ const TaskListV2: React.FC = () => { project_id: urlProjectId, }; + // Update the Redux store immediately for optimistic updates + const currentTask = allTasks.find(task => task.id === taskId); + if (currentTask) { + const updatedTask = { + ...currentTask, + custom_column_values: { + ...currentTask.custom_column_values, + [columnKey]: value, + }, + updated_at: new Date().toISOString(), + }; + + // Import and dispatch the updateTask action + import('@/features/task-management/task-management.slice').then(({ updateTask }) => { + dispatch(updateTask(updatedTask)); + }); + } + if (socket && connected) { socket.emit(SocketEvents.TASK_CUSTOM_COLUMN_UPDATE.toString(), JSON.stringify(body)); } else { @@ -291,7 +309,7 @@ const TaskListV2: React.FC = () => { } catch (error) { console.error('Error updating custom column value:', error); } - }, [urlProjectId, socket, connected]); + }, [urlProjectId, socket, connected, allTasks, dispatch]); // Custom column settings handler const handleCustomColumnSettings = useCallback((columnKey: string) => { @@ -317,11 +335,9 @@ const TaskListV2: React.FC = () => { // The global socket handler will handle the real-time update }, []); - // Handle scroll synchronization + // Handle scroll synchronization - disabled since header is now sticky inside content const handleContentScroll = useCallback(() => { - if (headerScrollRef.current && contentScrollRef.current) { - headerScrollRef.current.scrollLeft = contentScrollRef.current.scrollLeft; - } + // No longer needed since header scrolls naturally with content }, []); // Memoized values for GroupedVirtuoso @@ -454,7 +470,7 @@ const TaskListV2: React.FC = () => { // Render column headers const renderColumnHeaders = useCallback(() => ( -