Closed (fixed)
Project:
Open Social
Version:
11.1.x-dev
Component:
Code (back-end)
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
20 Jan 2017 at 14:23 UTC
Updated:
30 Aug 2022 at 15:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ronaldtebrake commentedComment #3
jochemvn commentedComment #4
peter.polman commentedComment #5
ronaldtebrake commentedComment #6
mohit_aghera commentedComment #7
peter.polman commentedHey mohit!
I see you are willing to fix this crit, very nice! I looked into it a few days ago and I guess it's gonna be a bit tricky (at least for me). The approach our team thought might work was like this:
Setting up a regex filter (scanning for the particular prefix and suffix) that fires on the input event of the textarea and does an AJAX call to retrieve the username and replace the string found in the contents might work! That for the changing value of the textarea dynamically, but in the form_alter this can probably be done through some already existing functions so we dont have to execute some JS on page load.
Hope it might give you a head start or maybe you already have a better approach:) Good luck!
Comment #8
mohit_aghera commentedMy doubt is bit different. If we replace [~2] with user name in text area, then on entity preserve we will have to replace it again with actual value
So it is there any filter format that we can use it just to replace text [~2] with relevant user name so actual user name will be intact and there will be less processing.
I'm digging codebase of opensocial to get some more insight around this.
Comment #9
peter.polman commentedFiddle: https://jsfiddle.net/aL910068/1/
Approach 1:
I was playing around with this one today a bit. Replacing the values of the textarea based on the known mention uids and names is possible with some regexes, but converting everything back when updating the hidden input would be way to performance heavy. It's already running slow in the fiddle I created.
Approach 2:
I thought of another approach that could have some perf benefits since it would handle replacements serverside in a preprocess function. Maybe this helps you a bit in finding something that works. I'm not sure how to hook this into the existing mention or Drupal logic, but this feels already a bit better than the previous idea:P
Curious what you come up with!
Comment #10
mohit_aghera commentedHi @peterpolman
I have attached initial patch, it is working partially. However, i need some inputs from you.
I have used following approach:
- In form alter, get the value of form field and run it through field processor
- Pass processed value in js as drupalSettings
- In js set value using .val() jquery function.
P.S. Right now i've build kind of idea about approach, currently i am figuring out about making it generic so it should work for any fields.
Comment #11
mohit_aghera commentedHi @peterpolman
This is updated patch, I forgot to include one plugin file at the top of .module file.
One more thing i would like to mention here is: we have to enable "Mentions" filter over here "admin/config/content/formats/manage/full_html"
Comment #12
peter.polman commentedAlso had to enable the mentionFilter for the used input types on that page, but it worked perfect after that. Good approach!
So for now we still need a solution for updating the hidden input field with the correct string containing the unformatted mention values. Otherwise we will store strings instead of mentions after editing and saving a post.
We could provide an array in the drupalSettings object containing the unformatted and formatted strings of a mention. And then regex on the usernames after all to provide the corresponding [~*] values in the hidden input. Maybe setup a new eventlistener for the input event on the textarea for that.
I like to hear what you think would be smart to do!
Comment #13
bairlangga commentedhi all, just want to bump up this issue since I'm having it now on 1.2, hopefully the patch will be incorported into next 1.3?
I've tried to run it but it failed to patch the last module (third one):
$ git apply incorrect_display_of-2845325-11.patch
error: patch failed: modules/social_features/social_mentions/social_mentions.module:9
error: modules/social_features/social_mentions/social_mentions.module: patch does not apply
Comment #14
bairlangga commentedHi, now that i've tried patch #10 it resulted to 2 fatal errors.
Fatal error: Call to a member function getEntityTypeId() on null in D:\www\kantek\html\core\modules\comment\src\CommentForm.php on line 240
Fatal error: Class 'MentionsFilter' not found in D:\www\kantek\html\profiles\contrib\social\modules\social_features\social_mentions\social_mentions.module on line 52
I gI shall revert the patch then... *sigh*
Comment #15
mohit_aghera commented@bairlangga
I will check it out today and provide updated patch.
There are few js fixes are also require in this patch. I'll try to accommodate that as well.
Comment #16
bramtenhove commentedI'm changing the priority to normal as the functionality of mentioning does not break.
Next to that I'm also not sure if this is a bug report or a change request. But I'll leave it as it is for now.
@mohit_aghera, if you find some time to update the patch that would be great!
Comment #17
ronaldtebrake commentedUpdating it to 3.x - still needs work.
Comment #18
xinyuma commentedComment #19
navneet0693 commentedPR: https://github.com/goalgorilla/open_social/pull/2691
Comment #20
axael commentedAs a small add-on, I do have this issue as well when trying to mention someone on the site with the account of the UID 1.
(not while trying to edit a comment / post, but when adding a new comment / post)
Comment #21
navneet0693 commented@Axael I changing it back to 'Needs Review' and '11.1.x-dev' as I believe that it was accidental.
Comment #22
ressinelComment #23
tbsiqueiraComment #25
tbsiqueira