Harvest-Dev / ng-select2

A select2 for Angular
MIT License
52 stars 32 forks source link

Single Select Add New #55

Closed majora2007 closed 11 months ago

majora2007 commented 1 year ago

I'm trying to use this to add a new item to a list of existing options (autoCreate), however i do not see any input.

From the documentation and the code it seems possible, but I'm not seeing how to get it to happen. (Edit: It doesn't seem possible on single mode)

If this is not possible, are you open to a PR or enhancement? I really need this ability along with a separate event for when a new item is added (multiple or not).

<select2 [data]="smartFilters"
                     id="filter-name"
                     formControlName="name"
                     (update)="updateFilterValue($event)"
                     [autoCreate]="true"
                     [multiple]="false"
                     [infiniteScroll]="false"
                     [resettable]="true">
            </select2>

image

Zefling commented 1 year ago

I'm sorry, currently autoCreate is only available with multiple=true

In single mode, the field just needs to be editable. We should see how to integrate without breaking the use of templates.

majora2007 commented 1 year ago

I'll take a few stabs at it. I'm yet again going on a holiday, so I wont get to it till + 1 week's time.

majora2007 commented 11 months ago

Just got back from holiday, so will take a stab at this.

Zefling commented 11 months ago

See version 13.0.9 ;)

majora2007 commented 11 months ago

Thanks! As I was integrating, I thought of some small enhancements to streamline the UX. I'll try to get a PR open for discussion.