Open jiji-Bi opened 1 year ago
any textfield or input isn't triggering onChange event from keyboard ... i need the rows of the taks list table to be editable any idea how can i get it to work ?
actually i found my own solution for this it was just about extracting the whole table logic outside the gant chart while keeping the same UI ....but tbh still wondering what is preventing the event to be fired from keyboard
https://github.com/MaTeMaTuK/gantt-task-react/pull/217 - this PR should fix the original issue and allow onChange, if you have any suggestions how I can improve this to ensure that the arrow keys don't get passed through that would be great. Currently I have to check in each input if there is a keydown and then stop propogation.
import React, { useState, useMemo } from "react"; import styles from "./task-list-table.module.css"; import { useDispatch } from 'react-redux'; import { updateTasks } from '../../features/SuperAdminPages/tacheSlice' import { TextField} from '@mui/material';
const localeDateStringCache = {}; const toLocaleDateStringFactory = (locale) => { return (date, dateTimeOptions) => { const key = date.toString(); let lds = localeDateStringCache[key]; if (!lds) { lds = date.toLocaleDateString(locale, dateTimeOptions); localeDateStringCache[key] = lds; } return lds; }; }; const dateTimeOptions = { weekday: "short", year: "numeric", month: "long", day: "numeric", };
const TaskListTableDefault = ({ rowHeight, rowWidth, tasks, fontFamily, fontSize, locale, onExpanderClick, onCellEdit, }) => {
const dispatch = useDispatch(); const [editingRowId, setEditingRowId] = useState(null); const toLocaleDateString = useMemo(() => toLocaleDateStringFactory(locale), [locale]);
const handleNameBlur = (taskId, newName, e) => { handleSaveChanges(taskId, { name: newName }); };
const handleRowClick = (rowId) => { console.log('okay') setEditingRowId((prevRowId) => (prevRowId === rowId ? null : rowId)); };
const handleSaveChanges = (rowId, newData, e) => { const updatedTasks = tasks.map((task) => task.id === rowId ? { ...task, ...newData } : task ); dispatch(updateTasks(updatedTasks)); setEditingRowId(null); };
const handleCancelEdit = () => { setEditingRowId(null); };
const handleCellEdit = (taskId, columnName, newValue) => {
};
return ( <div className={styles.taskListWrapper} style={{ fontFamily: fontFamily, fontSize: fontSize, }}
); };
export default TaskListTableDefault;