Skip to content

Commit

Permalink
Close the modal once task is complete and if modal is already open
Browse files Browse the repository at this point in the history
  • Loading branch information
aulisius committed Dec 14, 2022
1 parent e7fd1c5 commit f92dc34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/MinimalCard.js
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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 = {
Expand Down

0 comments on commit f92dc34

Please sign in to comment.