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

AutoComplete: V4 Chips Component was Deprecated, AutoComplete with the multiple param does not allow the very convenient addOnBlur or separator params #6611

Open
duganbrianj opened this issue Oct 20, 2024 · 1 comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add

Comments

@duganbrianj
Copy link

duganbrianj commented Oct 20, 2024

Describe the bug

AutoComplete with the multiple param does not currently have two very convenient features of the Chips component. The chips component worked much better for allowing users to add their own inputs because of the addOnBlur and separator params.

Would be awesome to have that functionality added to the AutoComplete component, since I don't think people can consistently rely on users pressing enter after typing freeform text. I think that works if there are pre-determined options with the dropdown, but does not work when it's just trying to get users to enter array items.

Reproducer

https://stackblitz.com/edit/primevue-4-vite-issue-template-888z42?file=README.md,src%2FApp.vue

PrimeVue version

4.1.0

Vue version

4.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

  1. Within the AutoComplete component, there's no ability to use addOnBlur or separator params that existed with the Chips component. There's no convenient way for a user to write "tag1" and click off the component for "tag1" to become an item if there isn't a predetermined list that includes "tag1" as an option. Same with using a comma to separate tag values, pressing enter is a work around, but removes the ability for a user to paste in a comma separated list.

Expected behavior

Ideally, if a user has anything typed in the component and clicks off the component, that text would become a chip when addOnBlur is a param. And when separator is a param, having separator="," would allow the user to paste a comma separated list with each item properly getting added as a chip. These features existed in the now deprecated Chips component, and without these features I don't think AutoComplete replaces the functionality offered by the Chips component

@duganbrianj duganbrianj added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 20, 2024
@CCodam
Copy link

CCodam commented Oct 20, 2024

You're not alone #5909

The AutoComplete component uses the InputChips component behind the scenes.
While this component is not documented, it's virtually identical of the v3 Chips component, and you should be able to use the v3 Chips documentation to accomplish your goals with it.
You will however get a Deprecated since v4 notice in your console.

I guess they don't want InputChips as a separate documented component in v4, as they feel the AutoComplete should encompass the same functionality.

To that end, functionality needs to be added back into the AutoComplete component.
I haven't looked too deep into the code, maybe there's a smart way to utilize the logic already present in the underlying InputChips component, otherwise modification of the existing AutoComplete logic is needed

I've modified the onChange and onInput methods of the AutoComplete component, and added an onPaste method and separator value.
I've decided to always add chip onChange (essentially onBlur), if all other conditions are met, typeahead (false), forceSelection (false), multiple (true). However addOnBlur could of course be added.
The InputChips component works out of the box, without modifications.
https://stackblitz.com/edit/primevue-4-vite-issue-template-muvzf2?file=src%2FApp.vue

This is just a rough implementation, that hopefully can inspire a pull request, that'll add the functionality "back" into the AutoComplete component.

@tugcekucukoglu tugcekucukoglu added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

3 participants