tracker hover fix

This commit is contained in:
Николай Полтщук 2023-05-03 20:26:09 +03:00
parent cd732dcc9d
commit efca4f0818

View File

@ -30,12 +30,7 @@ export const ProjectTracker = () => {
const [openColumnSelect, setOpenColumnSelect] = useState({}) const [openColumnSelect, setOpenColumnSelect] = useState({})
const [selectedTab, setSelectedTab] = useState(0); const [selectedTab, setSelectedTab] = useState(0);
const startWrapperIndexTest = useRef({}) const startWrapperIndexTest = useRef({})
const [wrapperHover, setWrapperHover] = useState([ const [wrapperHover, setWrapperHover] = useState({});
false,
false,
false,
false,
]);
const projectBoard = useSelector(getProjectBoard); const projectBoard = useSelector(getProjectBoard);
useEffect(() => { useEffect(() => {
dispatch(setProjectBoardFetch(projectId.id)) dispatch(setProjectBoardFetch(projectId.id))
@ -45,6 +40,7 @@ export const ProjectTracker = () => {
if (Object.keys(projectBoard).length) { if (Object.keys(projectBoard).length) {
projectBoard.columns.forEach(column => { projectBoard.columns.forEach(column => {
setOpenColumnSelect(prevState => ({...prevState, [column.id]: false})) setOpenColumnSelect(prevState => ({...prevState, [column.id]: false}))
setWrapperHover(prevState => ({...prevState, [column.id]: false}))
}) })
} }
}, [projectBoard]) }, [projectBoard])
@ -80,9 +76,8 @@ export const ProjectTracker = () => {
} }
function dragEndHandler(e) { function dragEndHandler(e) {
setWrapperHover((prevArray) => setWrapperHover(prevState => ({
prevArray.map((elem) => { [prevState]: false
return false;
}) })
); );
e.target.classList.remove("tasks__board__item__hide"); e.target.classList.remove("tasks__board__item__hide");
@ -96,24 +91,19 @@ export const ProjectTracker = () => {
if (columnId === startWrapperIndexTest.current.index) { if (columnId === startWrapperIndexTest.current.index) {
return; return;
} }
setWrapperHover((prevArray) =>
prevArray.map((elem, index) => { setWrapperHover(prevState => ({
if (index === columnId) { [prevState]: false, [columnId]: true
return true; }))
} else {
return false;
}
})
);
} }
function dragDropHandler(e, columnId) { function dragDropHandler(e, columnId) {
e.preventDefault(); e.preventDefault();
if (startWrapperIndexTest.current.index === columnId) { if (startWrapperIndexTest.current.index === columnId) {
return; return;
} }
setWrapperHover((prevArray) =>
prevArray.map((elem) => { setWrapperHover(prevState => ({
return false; [prevState]: false
}) })
); );