From f92dc342de3caf5688f4624ac439bfc828a2aa66 Mon Sep 17 00:00:00 2001 From: aulisius Date: Wed, 14 Dec 2022 13:55:56 +0530 Subject: [PATCH] Close the modal once task is complete and if modal is already open --- src/components/MinimalCard.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/MinimalCard.js b/src/components/MinimalCard.js index 804c3f35..808d0525 100644 --- a/src/components/MinimalCard.js +++ b/src/components/MinimalCard.js @@ -1,4 +1,4 @@ -import { useState } from "@wordpress/element"; +import { useEffect, useState } from "@wordpress/element"; import { ReactComponent as CompletedTask } from "../icons/task-completed-solid.svg"; import ModalCard from "./ModalCard"; @@ -7,6 +7,11 @@ export function MinimalCard(props) { let modal = props.modal(); let { image: Icon } = props.assets(props.state); const taskCompleted = props.state.taskCompleted; + useEffect(() => { + if (taskCompleted && showModal) { + setShowModal(false); + } + }, [taskCompleted, showModal]); let { title, actionName } = props.text(taskCompleted); const buttonClickHandler = () => { const data = {