Bug: newCommentValue empty on comment submission

  • Goal: Pass newCommentValue value to query event handler on submit

  • Steps: the only other mention of this problem I found was here where the suggested solution by OP was to add debounce which is not working for me. When I hit submit, the newCommentValue is empty as shown in this image:


    I have also tried to use the last comment in the comments array but that will pick up the last comment already in the array, not the one to be added as suggested in the aforementioned link.
    i.e. {{notesComment.comments[notesComment.comments.length-1].value}}

However, on the query itself, if I click RUN while I have some value in the comment box, it will be passed in the query as shown here.

So the bug is when clicking submit the newCommentValue is lost.

I'm also curious to understand where these comments are stored. My goal is to have some kind of customer notes left of a customer profile, it is currently linked by the customer ID and I am storing this in the database but it is storing it somewhere else too since it does not require a query to store the comments.

thanks!

I haven't really used the comments component in my apps, but I can tell you what I see from poking around with it a bit:

The value of newCommentValue is only stored temporarily. When the submit button is clicked, the value goes into the comments array of the component and newCommentValue is cleared. This is why adding a debounce to your DB submit query (essentially, waiting for this to happen for a few milliseconds) and changing the value you are inserting to {{notesComment.comments[notesComment.comments.length-1].value}} (the last comment, which is the one you just submitted) should work.

When you click RUN with a (non-submitted) value in the comments entry box, it works because the value is not yet in the comments array and newCommentValue is not yet cleared, but then you could change the comment before adding it to the comments list and your DB would be out of sync with the app.

But the question you raise is a good one - I don't know where the comments array is stored (one would think the DB, but I can't see it).

@victoria - you were on the other thread, can you give us some insight here about where the comments array lives and how best to work with it?

thanks @jg80 !

adding a debounce to your DB submit query (essentially, waiting for this to happen for a few milliseconds) and changing the value you are inserting to

this does indeed work but has the consequence of missing a comment if there is another one placed between making a comment and the query running. I could try blocking another comment from being made until the query has run, but something like that shouldn't be necessary and overcomplicates a simple feature. Not having full control over the data in the comments (potentially two sources of truths) means this component isn't ideal in my use case—a note-taking log.

I think it is safer to try and re-create the comments feature using other components. Thanks again for your help!