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

Fix TagsInput duplicate deletion behavior #6907

Merged
merged 1 commit into from
Sep 28, 2024

Conversation

ctdunc
Copy link
Contributor

@ctdunc ctdunc commented Sep 27, 2024

fixes #6873

@rtivital rtivital merged commit d6f0e1d into mantinedev:master Sep 28, 2024
1 check passed
@rtivital
Copy link
Member

Thanks!

@@ -336,7 +336,7 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => {
key={`${item}-${index}`}
withRemoveButton={!readOnly}
onRemove={() => {
setValue(_value.filter((i) => item !== i));
setValue(_value.splice(index, 1));

Choose a reason for hiding this comment

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

Is this correct? I'm seeing that clicking X to remove a tag now removes all other tags except the target

Copy link
Contributor Author

Choose a reason for hiding this comment

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

think I should've used .toSpliced here @adelamarAtGalileo can you let me know if this resolves it?

Seems alright to me, but clearly I missed it yesterday. Storybook must not have refreshed 🤷.

Choose a reason for hiding this comment

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

splice modifies the array and returns the removed value

Screenshot 2024-09-30 at 1 55 04 PM

toSpliced doesn't modify the array and returns the remaining values

Screenshot 2024-09-30 at 1 57 00 PM

So yes, .toSpliced should work here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

skill issue (on my behalf). I've opened a PR. Thanks for catching :)

Copy link
Contributor

Choose a reason for hiding this comment

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

nice, hopefully released soon, already got complaints from users :D

Copy link

@adelamarAtGalileo adelamarAtGalileo Oct 2, 2024

Choose a reason for hiding this comment

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

@max-degterev You can downgrade to "@mantine/core": "^7.11.1" so you can avoid the newly introduced bug while waiting for a new release with the fix

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe @rtivital pushes this out soon, I keep my hopes up :)

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.

Deleting element in TagsInput with allowDuplicates=True deletes all duplicate elements
4 participants