Skip to content

fix(mention): custom range for usernames and error handling#12657

Open
hamza221 wants to merge 1 commit intomainfrom
fix/mentio-users
Open

fix(mention): custom range for usernames and error handling#12657
hamza221 wants to merge 1 commit intomainfrom
fix/mentio-users

Conversation

@hamza221
Copy link
Copy Markdown
Contributor

Fixed Bugs:

  1. when searching for a user after typing @ and your query is longer than 5 characters the user is added to to but the text is never replaced
  2. If your results contain contacts with null emails you get no suggestions and it fails silently
  3. Error handling for the http request

Should be probably generalized for all triggers mainly Text blocks and links

Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
contactResults = await autoCompleteByName(text)
contactResults = contactResults.filter((result) => result.email?.filter((email) => email.length > 0))
} catch (error) {
console.error(error)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the logger with a meaningful log message. log the error as context

}
if (eventData.marker === '@') {
this.editorInstance.execute('insertItem', { email: item.email[0], label: item.label }, '@')
const lookback = this.contactMentionQuery?.length + 1 || 5 // +1 for the '@' itself
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works, but adding +1 to a possible undefined and then falling back to another value is hard to read

> const obj = {}
undefined
> obj?.foo + 1 || 5
5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants