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

Deleting element in TagsInput with allowDuplicates=True deletes all duplicate elements #6873

Closed
2 tasks done
ctdunc opened this issue Sep 24, 2024 · 3 comments · Fixed by #6907
Closed
2 tasks done

Comments

@ctdunc
Copy link
Contributor

ctdunc commented Sep 24, 2024

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

^7.6.2

What package has an issue?

@mantine/core

What framework do you use?

Other, I will specify in the bug description

In which browsers you can reproduce the issue?

All

Describe the bug

I am using mantine through dash-mantine-components, but have confirmed that this issue also appears on the mantine website.

For example, given a tags input containing items=['a','b','a'], clicking delete on items[2] also deletes items[0].

If possible, include a link to a codesandbox with a minimal reproduction

https://mantine.dev/core/tags-input/#allow-duplicates

Possible fix

Clicking delete on a tag should delete only that tag.

Possibly here

setValue(_value.filter((i) => item !== i));

Maybe something like this? If duplicates aren't allowed, the behavior will be identical. If duplicates are allowed, it will only remove the desired element.

 onRemove={() => {
        let _ = _value.splice(index, 1)
        setValue(_value);
        onRemove?.(item);
      }}

Self-service

  • I would be willing to implement a fix for this issue
@ctdunc
Copy link
Contributor Author

ctdunc commented Sep 27, 2024

If this is expected behavior, ill close this issue. Otherwise happy to submit a fix, just let me know.

Thanks!

@rtivital
Copy link
Member

You are welcome to submit a PR with a fix

@ctdunc
Copy link
Contributor Author

ctdunc commented Nov 11, 2024

BTW -- fixed an issue here surrounding controlled components not triggering on x click #7105

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 a pull request may close this issue.

2 participants