Skip to content
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

Fixed spacing bug after mentions in comments #3252

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

harmitgoswami
Copy link
Collaborator

Fix #2840

Fixed styling bug for comments, in which there was no automatic space appended after mentioning a user using @[name]. The bug was resolved by explicitly setting the cursor to the end of the editor's content, thereby ensuring that the space was added in the correct location within the editor.

To reproduce results: After starting up the server, navigate to any translated string within any team/project. Then, click the "COMMENT" button on that string, and type "@[any letter]" to bring up a list of users to mention in your comment. Choose any user using either your cursor or the arrow keys + tab, then type the rest of your comment. There should be a space automatically added after the mention, before the content of your comment.

image

@harmitgoswami harmitgoswami requested a review from eemeli June 5, 2024 19:05
@mathjazz
Copy link
Collaborator

mathjazz commented Jun 5, 2024

I wonder if we can avoid the edge case - if you add a mention in the middle of the comment.

@harmitgoswami
Copy link
Collaborator Author

I wonder if we can avoid the edge case - if you add a mention in the middle of the comment.

Seems like simply adding editor to the dependency array of the useCallback did the trick :D

image

Transforms.insertText(editor, ' ');
},
[],
[editor],
Copy link
Member

Choose a reason for hiding this comment

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

This addition is fine, but unnecessary in this case as the value is coming from useMemo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So let's remove that?

It doesn't seem to fix the problem where you add a mention in the middle of the comment - when you insert it, the space is added to the end of the string and the cursor jumps there, too.

Copy link
Member

Choose a reason for hiding this comment

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

Including the editor as a dependency is nominally good practice; skipping it is such a marginal optimization that it doesn't matter. Either way goes, and neither is wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok, makes sense!

@mathjazz mathjazz merged commit 17965f2 into mozilla:main Jun 6, 2024
4 checks passed
@harmitgoswami harmitgoswami deleted the mention-space branch June 6, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add space after mentions
3 participants