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

MultiSelect - showToggleAll not working as expected #16039

Closed
dfernandez-elastic opened this issue Jul 17, 2024 · 0 comments · Fixed by #16041
Closed

MultiSelect - showToggleAll not working as expected #16039

dfernandez-elastic opened this issue Jul 17, 2024 · 0 comments · Fixed by #16041
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working v18-port
Milestone

Comments

@dfernandez-elastic
Copy link
Contributor

dfernandez-elastic commented Jul 17, 2024

Describe the bug

When using MultiSelect, we have a use case where we need to pass the selectionLimit prop conditionally. Like this:

<p-multiSelect 
    [options]="cities" 
    [(ngModel)]="selectedCities" 
    optionLabel="name"
    [showToggleAll]="true"
    [selectionLimit]="someCondition ? '3' : null" 
    placeholder="Select Cities" />

This is the most recommended way to pass props conditionally.

So, in the MultiSelect component, you have a method to show/hide the Toggle All checkbox. The problem comes in this line where you are transforming the selectionLimit variable. When passing null or undefined, this transform is transforming the variable to NaN, so later your isSelectionAllDisabled method is not working as expected because ObjectUtils.isEmpty(NaN) is false.

At the end, when passing null or undefined to the selectionLimit prop, we end up not showing the Toggle All checkbox at all.

Do you have a workaround? Or other recommended way?

Thanks a lot

Last note:

Angular people told me that this is the expected behaviour for the numberAttribute transform

Environment

Reproducer

https://stackblitz.com/edit/pi4qot?file=src%2Fapp%2Fmulti-select-basic-demo.html

Angular version

18.1.0

PrimeNG version

17.18.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v22.4.1

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

I should see the Toggle All checkbox when passing null or undefined to the selectionLimit prop

@dfernandez-elastic dfernandez-elastic added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 17, 2024
@cetincakiroglu cetincakiroglu added this to the 17.18.5 milestone Jul 18, 2024
@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 Jul 18, 2024
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 v18-port
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants