shuashuai commented on code in PR #1014:
URL: https://github.com/apache/incubator-answer/pull/1014#discussion_r1675426040


##########
ui/src/pages/Questions/Ask/index.tsx:
##########
@@ -137,13 +134,28 @@ const Ask = () => {
 
   useEffect(() => {
     if (!qid) {
-      initQueryTags();
+      // order: 1. tags query. 2. prefill query. 3. draft
+      const queryTags = searchParams.get('tags');
+      if (queryTags) {
+        updateTags(queryTags);
+      }
       const draft = storageExpires.get(DRAFT_QUESTION_STORAGE_KEY);
-      if (draft) {
-        formData.title.value = draft.title;
-        formData.content.value = draft.content;
-        formData.tags.value = draft.tags;
-        formData.answer_content.value = draft.answer_content;
+
+      const prefill = searchParams.get('prefill');
+      if (prefill || draft) {
+        if (prefill) {
+          const file = matter(decodeURIComponent(prefill));
+          formData.title.value = file.data?.title;
+          formData.content.value = file.content;
+          if (!queryTags && file.data?.tags) {
+            updateTags(file.data.tags);
+          }
+        } else if (draft) {
+          formData.title.value = draft.title;
+          formData.content.value = draft.content;
+          formData.tags.value = draft.tags;
+          formData.answer_content.value = draft.answer_content;
+        }

Review Comment:
   add this line to else if 
   
   ```
   else if (draft) {
             formData.title.value = draft.title;
             formData.content.value = draft.content;
             formData.tags.value = draft.tags;
             formData.answer_content.value = draft.answer_content;
             
             setCheckState(Boolean(draft.answer_content));
             setHasDraft(true);
           }
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to