Skip to content

Commit fedc7f4

Browse files
danxuliunextcloud-command
authored andcommitted
Fix mention bubbles not rendered in comment editor
The NcRichContenteditable requires the "userData" property to be given to render the mention bubbles. Otherwise after selecting a candidate mention just "@" followed by the user id is shown in plain text. To solve that now the data of the candidate mentions is cached whenever the autocomplete list is shown, and reset once a comment has been sent. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent cc83222 commit fedc7f4

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

apps/comments/src/components/Comment.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<NcRichContenteditable ref="editor"
6969
:auto-complete="autoComplete"
7070
:contenteditable="!loading"
71+
:user-data="userData"
7172
:value="localMessage"
7273
@update:value="updateLocalMessage"
7374
@submit="onSubmit" />

apps/comments/src/views/Comments.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
:auto-complete="autoComplete"
2929
:editor="true"
3030
:ressource-id="ressourceId"
31+
:user-data="candidateMentionsData"
3132
class="comments__writer"
3233
@new="onNewComment" />
3334

@@ -127,6 +128,7 @@ export default {
127128
actorId: getCurrentUser().uid,
128129
key: 'editor',
129130
},
131+
candidateMentionsData: {},
130132
131133
Comment,
132134
}
@@ -251,7 +253,14 @@ export default {
251253
limit: loadState('comments', 'maxAutoCompleteResults'),
252254
},
253255
})
254-
return callback(results.data.ocs.data)
256+
257+
const candidateMentions = results.data.ocs.data
258+
259+
candidateMentions.forEach(candidateMention => {
260+
this.candidateMentionsData[candidateMention.id] = candidateMention
261+
})
262+
263+
return callback(candidateMentions)
255264
},
256265
257266
/**
@@ -261,6 +270,8 @@ export default {
261270
*/
262271
onNewComment(comment) {
263272
this.comments.unshift(comment)
273+
// Reset cached candidate mentions
274+
this.candidateMentionsData = {}
264275
},
265276
266277
/**

dist/comments-comments-app.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)