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

Inserting a mention in between text results in text to be duplicated #7014

Closed
chaowss opened this issue Aug 9, 2024 · 1 comment · Fixed by #7017
Closed

Inserting a mention in between text results in text to be duplicated #7014

chaowss opened this issue Aug 9, 2024 · 1 comment · Fixed by #7017
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@chaowss
Copy link
Contributor

chaowss commented Aug 9, 2024

Describe the bug

Whenever inputing a mention between text (for instance if someone were to replace a mention after they typed the continuation of their message), the beginning of the text gets repeated and there is also the original text there.

Screen.Recording.2024-08-09.at.4.44.53.PM.mov

Reproducer

No response

System Information

This is the demo on https://primereact.org/mention/

Steps to reproduce the behavior

input a mention between two strings, observe that the mention is appended to the old string with all of the characters preceding it repeated.

Expected behavior

It should just input the mention correctly without repeating text.

@chaowss chaowss added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Aug 9, 2024
chaowss added a commit to chaowss/primereact that referenced this issue Aug 10, 2024
… text

The issue was that event.target is not the prompt form but actually a list item element,
which doesn't have the selectionStart attribute.

I've also added a change where inserting the mention in front of a space does not result in a double space.
chaowss added a commit to chaowss/primereact that referenced this issue Aug 10, 2024
… text

The issue was that event.target is not the prompt form but actually a list item element,
which doesn't have the selectionStart attribute.

I've also added a change where inserting the mention in front of a space does not result in a double space.
@chaowss
Copy link
Contributor Author

chaowss commented Aug 10, 2024

Created the above PR ^ to fix

@chaowss chaowss changed the title Inserting a mention between text leads the first Inserting a mention in between text results in text to be duplicated Aug 10, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Aug 10, 2024
@melloware melloware added this to the 10.8.3 milestone Aug 10, 2024
melloware pushed a commit that referenced this issue Aug 11, 2024
* fixes issue #7014: inserting mentions results in duplicated text

The issue was that event.target is not the prompt form but actually a list item element,
which doesn't have the selectionStart attribute.

I've also added a change where inserting the mention in front of a space does not result in a double space.

* check to add space only if space is at beginning of nextText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants