Skip to:
Content

BuddyPress.org

Opened 11 months ago

Last modified 9 months ago

#8001 new task

Review at.js integration for updates and/or swapout

Reported by: boonebgorges Owned by:
Milestone: Up Next Priority: normal
Severity: normal Version:
Component: Core Keywords: needs-testing
Cc:

Description

Previously: #7928

According to https://github.com/ichord/At.js/commit/a42b3182a9433506eabf8aaaa5eeb653561a27e7, At.js is no longer maintained. We should explore swapping out with a maintained package. https://github.com/zurb/tribute is recommended, but I have no idea how different the API is.

If we maintain the library, we could monkey-patch fixes like https://github.com/ichord/At.js/issues/321#issuecomment-319516017

Attachments (1)

8001.tribute01.diff (268.3 KB) - added by dcavins 9 months ago.
Use Tribute for @-lookups of users.

Download all attachments as: .zip

Change History (4)

#2 @dcavins
9 months ago

I'm attaching a patch that introduces Tribute in favor of At-who. I'm not sure that this is a clear improvement (it trades one kind of complexity for another). Thoughts:

  • The division of labor is that the library watches the inputs we specify for the trigger @ and then compares the string after the @ to the values (user objects) you passed to it. It sorts the best match to the top of the list and handles keyboard and mouse interaction with the results list. Our wrapper handles the remote AJAX lookup and returns the fetched user objects to Tribute.
  • This library is large (48KB transfer and ~200KB unzipped) and does a lot more than we really need, like fuzzy matching from a list of possibilities. Our most typical case is a set of AJAX-fetched options in response to a query, so everything is a match. The only time that the fuzzy matching is used in our case is when the user is interacting with the pre-constructed friends list (generated by php and stored in the JS object BP_Suggestions.friends), which happens rarely.
  • Tribute gives each match a score to order the results. It would be cool to influence those results so that your friends are always on top. (Then we could also stop pre-caching friends in php.)
  • I was not able to get Tribute to work with the TinyMCE editor window. It seems possible, but I ran out of will in this session. (Also, what about Gutenberg blocks?)
  • I ran into some issues within Tribute where I thought I could pass options in to change the behavior and output, but the promising sub module options were hardcoded in the main module, so things that looked like options actually weren't. I imagine Zurb would consider accepting pull requests that were reasonable. (They'd actively like help with improving how the library works with TinyMCE, for instance.)

So, Tribute is promising, but maybe overkill for what we need (and not as flexible/easy to work with as we'd like). Let me know what you think.

@dcavins
9 months ago

Use Tribute for @-lookups of users.

#3 @boonebgorges
9 months ago

Thank you for working on this!!

It does sound like Tribute is a bit more than what we need today, but I like the idea that it's a well-maintained library that has features that we could one day leverage.

One key question I've got is: Does moving to Tribute fix some of the outstanding @-mention interface bugs that have come up in the last year? If it does, then it seems like a good move.

Regarding TinyMCE - can you remind me where in BP we supported the atwho interfare in TinyMCE? Was in in the messages area? Or in the Dashboard itself? (Side note that the swap-out breaks messages in Nouveau, which for some reason lists atwho directly as a dependency, rather than our wrapper)

#4 @dcavins
9 months ago

Re TinyMCE: With the atwho method, you can @mention users in post content and such from the WP dashboard. (It doesn't cause anything to happen, like a notification or a profile link, the user is just mentioned in the text of the post like "I had a nice chat with @username about BuddyPress".) I'm dubious about how useful it is, but I think we should be able to recreate it using Tribute, so that we don't lose a feature that someone loves dearly.

I'm not sure about the outstanding @-mention interface bugs. The only issues I knew of were accessibility problems, and, at first blush, Tribute does seem to resolve those (I'd love for @mercime to have a look).

I will look into handling the change in Nouveau as well, and will produce a new patch.

In other news, WP just started using at-who and caret on the support forums: https://meta.trac.wordpress.org/changeset/8064

Note: See TracTickets for help on using tickets.