1

I am trying to use ngx-chips for tag based dropdown. Below is the code that I am using:

   <tag-input [onlyFromAutocomplete]="true" formControlName="data">
        <tag-input-dropdown [identifyBy]="'data'" [showDropdownIfEmpty]="true" [autocompleteItems]="dataObject"  [appendToBody]="false"></tag-input-dropdown>
  </tag-input>

I am using the above code in bootstrap model. But when I tried to close the dropdown list clicking any where on model, it is not closing. So, I tried to add [appendToBody]="false" and it fixed the issue but now the position of dropdown got disturb.

Please let me know possible solution for it.

Community
  • 1
  • 1
Tavish Aggarwal
  • 1,020
  • 3
  • 22
  • 51

3 Answers3

4
keepOpen - [?boolean]

To use in conjunction with showDropdownIfEmpty. If set to false, the dropdown will not reopen automatically after adding a new tag. (defaults to true).

[keepOpen]="false"
MAnna
  • 41
  • 2
0

MAnnas answer helps, because the dropdownmenu wont open on entering keywords with the keyboard, but if you happen to click with the mouse and still open it, there is this:

add [appendToBody] = "false" to tag-input-dropdown and then add following CSS in global styles.css:

.ng2-dropdown-menu {
   position: absolute !important;
   left: 2% !important;
   top: 100% !important;
}

Credit goes to this Github issue

Khaled Ayed
  • 1,121
  • 3
  • 12
  • 29
connectedMind
  • 421
  • 4
  • 17
0

I hade the same issue, solution that worked for me was this: https://github.com/Gbuomprisco/ngx-chips/issues/783#issuecomment-546414947

Also adding [keepOpen]="false" made things better.