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

ListBox selection is not working from code #14121

Closed
ioantoader opened this issue Nov 15, 2023 · 2 comments
Closed

ListBox selection is not working from code #14121

ioantoader opened this issue Nov 15, 2023 · 2 comments
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ioantoader
Copy link

Describe the bug

Listbox component the selection binding is not working in "primeng": "16.7.2",

Hi have the folwing template:

<div class="card flex justify-content-center">
  <p-listbox
    [options]="virtualItems"
    [ngModel]="selectedItems"
    [style]="{ width: '15rem' }"
    [multiple]="true"
    [checkbox]="true"
    [showToggleAll]="false"
    [listStyle]="{'max-height': '220px'}"
    (onChange)="onListSelect($event)"
  ></p-listbox>
</div>
<div><button (click)="onSelect()">select</button></div>

and the ts:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'listbox-virtual-scroll-demo',
  templateUrl: './listbox-virtual-scroll-demo.html',
})
export class ListboxVirtualScrollDemo implements OnInit {
  virtualItems!: any[];

  selectedItems = [];

  ngOnInit() {
    this.virtualItems = [];
    for (let i = 0; i < 10; i++) {
      this.virtualItems.push('Item ' + i);
    }
  }

  public onSelect() {
    this.selectedItems = [this.virtualItems[1]];
    console.log(this.selectedItems);
  }

  public onListSelect(e) {
    this.selectedItems = e.value;
    console.log(this.selectedItems);
  }
}

when I press the button to select one item, nothing is selected. I can confirm is workin on version 16.6.0

Environment

Windows 10

Reproducer

No response

Angular version

16.2.0

PrimeNG version

16.7.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.18.2

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@ioantoader ioantoader added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 15, 2023
@cetincakiroglu cetincakiroglu added this to the 16.8.0 milestone Nov 16, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working 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 16, 2023
@cetincakiroglu
Copy link
Contributor

Hi,

Thanks for reporting the issue, it's fixed in 504aa92

@ioantoader
Copy link
Author

When will be release version 16.8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants