Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

how to add tags for articles? #151

Closed
CestcaVision opened this issue Apr 29, 2020 · 3 comments
Closed

how to add tags for articles? #151

CestcaVision opened this issue Apr 29, 2020 · 3 comments

Comments

@CestcaVision
Copy link

I tried many times to enter tags for new post. But it doesn't work. Does the tag need a format?

@jefflafay
Copy link

@Tricrepe did you figure it out? I was looking for the same information

@cirosantilli
Copy link

cirosantilli commented Mar 26, 2021

EDIT: found out, you have to hit the Enter key

What a terrible UI design, I could only figure it out after reading the source!!!

onKeyUp={this.watchForEnter} />
Requested UI improvement at: gothinkster/realworld#628

Furthermore, in the current reference react instance, trying to add tags during post creation fails with console message:

Uncaught TypeError: state.tagList.push is not a function

but you are able to add tags when editing posts.

Locally however, with the setup described below (this repo at 9186292) I don't get that bug, and I can also add tags at creation time. This suggests that the demo is just old, and that this problem has been fixed on master.

The reference live angular and vue setups work however.


Original comment

I reproduce with node express as described at: gothinkster/node-express-realworld-example-app#116

I then put a print on the server:

diff --git a/routes/api/articles.js b/routes/api/articles.js
index c17ca61..401448f 100644
--- a/routes/api/articles.js
+++ b/routes/api/articles.js
@@ -126,6 +126,8 @@ router.post('/', auth.required, function(req, res, next) {
   User.findById(req.payload.id).then(function(user){
     if (!user) { return res.sendStatus(401); }
 
+    console.error('asdf');
+    console.error(req.body.article);
     var article = new Article(req.body.article);
 
     article.author = user;

and when I create a new article it gives:

{ title: 'ti3', description: 'ab3', body: 'bo3', tagList: [] }

which suggests that it is a bug in React not sending the tags. When I check what the browser is sending on Chromium Developer, that is confirmed, tagList is empty:

article: {title: "title33", description: "desc2", body: "body2", tagList: []}

Ermm, actually the reference instance also currently has broken tags: https://demo.realworld.io/#/ ... but it is based on Angular instead of React...

@cirosantilli
Copy link

Found it out: you have to hit the Enter key, updated that info in my above comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants