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

SelectButton: Cannot deselect any buttons when allowEmpty=false and multiple=true #17576

Open
1 of 4 tasks
infe42 opened this issue Feb 5, 2025 · 0 comments
Open
1 of 4 tasks
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@infe42
Copy link

infe42 commented Feb 5, 2025

Describe the bug

When allowEmpty=false and multiple=true the buttons of a ButtonSelect component cannot be deselected at all. In PrimeNG versions prior to v18 the option allowEmpty=false only made sure that at least one button had to be selected. You could deselect buttons as usual as long as at least one button was still selected.

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

I'm not sure how to fix this.

The input allowEmpty is simply passed to all ToggleButton components, which seems wrong and undesired for multi-selection. Maybe it should be [allowEmpty]="allowEmpty || multiple"?

Reproducer

https://stackblitz.com/edit/github-eps8r4ln-z8wgvjvj?file=src%2Fapp%2Fapp.component.html

Environment

See Stackblitz.

The issue occurs with PrimeNG 18 and Angular 18.2 as well as with PrimeNG 19 and Angular 19.1. I have provided a Stackblitz for PrimeNG 19 and Angular 19.1.

Angular version

19.1.5

PrimeNG version

v19

Node version

No response

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to Stackblitz.
  2. Select more than one button, e.g. "A" and "B".
  3. Try to deselect any button.

Expected behavior

The component should behave like in PrimeNG 17 and before. allowEmpty should only prevent that all buttons are deselected. It should be possible to deselect buttons as long as at least one button is selected.

@infe42 infe42 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant