This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 8bdc43a435b54b52727fa8d60fe8ceebbb6caa43
Author: hgaol <[email protected]>
AuthorDate: Wed Jul 10 16:27:21 2024 +0800

    feat: support pre-fill forms on the ask page
---
 ui/src/pages/Questions/Ask/index.tsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ui/src/pages/Questions/Ask/index.tsx 
b/ui/src/pages/Questions/Ask/index.tsx
index 2b370de0..fb3b46ae 100644
--- a/ui/src/pages/Questions/Ask/index.tsx
+++ b/ui/src/pages/Questions/Ask/index.tsx
@@ -137,8 +137,16 @@ const Ask = () => {
 
   useEffect(() => {
     if (!qid) {
+      // order: 1. tags query. 2. prefill query. 3. draft
       initQueryTags();
-      const draft = storageExpires.get(DRAFT_QUESTION_STORAGE_KEY);
+      let draft;
+      const prefill = searchParams.get('prefill');
+      if (prefill) {
+        draft = JSON.parse(decodeURIComponent(prefill));
+      } else {
+        draft = storageExpires.get(DRAFT_QUESTION_STORAGE_KEY);
+      }
+
       if (draft) {
         formData.title.value = draft.title;
         formData.content.value = draft.content;

Reply via email to