-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Populate list of suggestions matching @mentions #6728
Conversation
38f04d8
to
7f8e3e9
Compare
62c5232
to
412f14c
Compare
450cb7f
to
c5c81e1
Compare
07dc484
to
07ebc15
Compare
22ee031
to
3397468
Compare
ec9ac59
to
be21b54
Compare
d82702a
to
547255d
Compare
79f6dbf
to
f05746e
Compare
f05746e
to
1c40e7d
Compare
38866b2
to
0756c83
Compare
5454fb3
to
516682a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general structure of this looks good. The main feedback I have is that I would try to do some follow-up refactoring where parts of this functionality such as the mentions popup component and text manipulation are extracted out of the MarkdownEditor
. This will make them easier to test on their own.
Maybe down the line it will also be useful to be able to reuse mentions functionality in some other non-markdown input (eg. imagine entering usernames to invite members to a group and getting suggestions), but I don't think you need to make it that general at this stage.
!activeMention || | ||
`${u.username} ${u.displayName ?? ''}` | ||
.toLowerCase() | ||
.match(activeMention.toLowerCase()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest pulling this out into a function with its own tests in future.
33038e7
to
0bfdf13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main feedback I have is that I think we could either drop or replace the term "suggestions" in some places, depending on whether it is clear that the thing being suggested is a user.
@@ -167,6 +167,9 @@ function AnnotationEditor({ | |||
|
|||
const textStyle = applyTheme(['annotationFontFamily'], settings); | |||
|
|||
const mentionsEnabled = store.isFeatureEnabled('at_mentions'); | |||
const usersWhoAnnotated = store.usersWhoAnnotated(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be super hard to filter out "self" later, if we decide that's the desired behavior.
0bfdf13
to
f45c930
Compare
Depends on #6727
Make the list of suggestions displayed when typing
@mentions
include matching users from those who already annotated the document and belong to the active group.The list is sorted by username and capped at 10 items.
at-mentions-suggestions-2025-01-16_14.29.37.mp4
Implementation decisions
The component needs to dynamically build a list of suggestions from the list of user that already annotated.
That list of users can be built from the list of annotations in the sidebar store. Since we had to fetch the annotations from the store somewhere, I decided to implement the list of users as a selector for the annotations store module.
It doesn't need to be accessed in many places, so it could have been a helper function on its own, but since the annotations had to be fetched from the store, it was convenient to do it this way.
Out of scope
There are many accessibility implications regarding the suggestions popover. This PR includes a couple of those, but I will dedicate a follow-up piece of work to address that properly and do a bit of extra investigation on how others handle it.
On top of that, I've found a small issue on theThis should be addressed by hypothesis/frontend-shared#1855Popover
component when it drops-up. If the contents change while it's open, causing it to get smaller, the position is not recalculated, so it ends up looking disconnected from its anchor element (the textarea in this case).Test steps
at_mentions
feature flag.Todo