primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.68k stars 1.01k forks source link

MultiSelect treats a value of zero for maxSelectedLabels as null #2966

Closed nathan-seddig-techedge closed 2 years ago

nathan-seddig-techedge commented 2 years ago

Describe the bug

I upgraded primereact from version 6.6.0 to version 8.0.0 and now setting the maxSelectedLabels of a MultiSelect to 0 appears to be equivalent to setting it to null, which causes all selected options to be displayed. Before the upgrade it caused the number of selected options to always be displayed, regardless of the selection. I believe this to be a bug and whish that the old behaviour, distinguishing between 0 and null, would be restored.

Reproducer

https://codesandbox.io/s/primereact-test-forked-77x2o7

PrimeReact version

8.1.1

React version

17.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a MultiSelect component
  2. Set maxSelectedLabels={0}
  3. Open the page and select an option
  4. The name of the selected option(s) is displayed instead of the number of selected options

Expected behavior

When maxSelectedLabels is set to 0, the number of selected options should always be displayed, including in the case in which no option is selected.

melloware commented 2 years ago

Thanks for reporting I will take a look!