Skip to content

Commit

Permalink
fix: new modals mouseonpane check fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mxerf committed Sep 30, 2024
1 parent c78d99d commit 59c0f06
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend/src/contexts/popUpContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnimatePresence } from "framer-motion"
import React, { createContext, ReactNode, useContext, useState } from "react"
import React, { createContext, ReactNode, useContext, useEffect, useState } from "react"
import { workspaceContext } from "./workspaceContext"

type PopUpContextType = {
Expand Down Expand Up @@ -27,13 +27,18 @@ const PopUpProvider = ({ children }: PopUpProviderProps) => {
const [popUpElements, setPopUpElements] = useState<{ id: string; element: JSX.Element }[]>([])
const [closingId, setClosingId] = useState<string | null>(null)


useEffect(() => {
setModalsOpened(popUpElements.length)
}, [popUpElements, setModalsOpened])

const openPopUp = (element: JSX.Element, id: string) => {
setModalsOpened((prev) => prev + 1)
// setModalsOpened((prev) => prev + 1)
setPopUpElements((prevPopUps) => [{ id, element }, ...prevPopUps])
}

const closePopUp = (id: string) => {
setModalsOpened((prev) => prev - 1)
// setModalsOpened((prev) => prev - 1)
setClosingId(id)
// Время ожидания анимации
setPopUpElements((prevPopUps) => prevPopUps.filter((popUp) => popUp.id !== id))
Expand Down

0 comments on commit 59c0f06

Please sign in to comment.