From 89a7d7413e60461958ce699288517b1fd417c0eb Mon Sep 17 00:00:00 2001 From: ayushpatel1248 <127100604+ayushpatel1248@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:12:59 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=80=20fix(QandA):input=20getting=20cle?= =?UTF-8?q?ared=20and=20auto=20closing=20the=20pop=20after=20the=20submiss?= =?UTF-8?q?ion=20(#1046)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit input should not get cleared if validaion is not matched and also question pop up should be closed if question is uploaded successfully fix issue #977 --- frontend/src/pages/Q&A/Q&A.jsx | 38 +++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/Q&A/Q&A.jsx b/frontend/src/pages/Q&A/Q&A.jsx index 8a4262f8..686f1522 100644 --- a/frontend/src/pages/Q&A/Q&A.jsx +++ b/frontend/src/pages/Q&A/Q&A.jsx @@ -5,7 +5,12 @@ import "./Ques.scss"; import Joi from "joi-browser"; import Loader from "../../components/util/Loader/index"; import { SimpleToast } from "../../components/util/Toast"; -import { getAllQuestion, uploadData, upvote, downvote } from "../../service/Faq"; +import { + getAllQuestion, + uploadData, + upvote, + downvote, +} from "../../service/Faq"; import { showToast, hideToast } from "../../service/toastService"; function Ques(props) { @@ -109,6 +114,7 @@ function Ques(props) { }); setFormErrors({}); setCheckedState(new Array(Tags.length).fill(false)); + setButtonPressed(false); }) .catch(() => { setIsUploadingData(false); @@ -129,7 +135,7 @@ function Ques(props) { await upvote(questionId, setToast); fetchQuestions(); }; - + const handleDownvote = async (questionId) => { await downvote(questionId, setToast); fetchQuestions(); @@ -164,7 +170,10 @@ function Ques(props) {

Created At {new Date(item.createdAt).toLocaleString()}

-

-
+
{formerrors["title"] ? (
* {formerrors["title"]}
) : ( @@ -254,8 +268,13 @@ function Ques(props) { value={formdata.description} onChange={handleChange} /> - -
+ +
{formerrors["body"] ? (
* {formerrors["body"]}
) : ( @@ -322,7 +341,10 @@ function Ques(props) {
-
+
{isUploadingData ? (