P-multiselect component ignores disabled options if optionLabel property is used #9346
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
I'm submitting a ... (check one with "x")
Plunkr Case (Bug Reports)
Please demonstrate your case at stackblitz by using the issue template below. Issues without a test case have much less possibility to be reviewd in detail and assisted.
https://stackblitz.com/edit/github-qsdqrk?file=src%2Fapp%2Fapp.component.ts
Current behavior
Whenever using a p-multiselect component and specifying an [optionLabel] property, the "disable" value of the SelectItems is ignored.
Expected behavior
Options of the p-multiSelect component should allow disabling even if the optionLabel property is used.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Fix the issue in the p-multiselect code
Please tell us about your environment:
OS: Windows 10, IDE: VisualStudioCode
Angular version:
Angular 7.2.12
PrimeNG version:
PrimeNg 7.1.3 (but is affecting master version as well)
Browser:
All browsers
Language:
Typescript 3.2.4
The issue is clear to reproduce and probably fix. The MultiSelect component "set options(val: any[])" method has the following line:
let opts = this.optionLabel ? ObjectUtils.generateSelectItems(val, this.optionLabel) : val;
and in ObjectUtils generateSelectItems method, the generated SelectItem is not copying the "disabled" property of the "val" object which it receives. Thus, even though the val object is marked as disabled, if the optionLabel was used (even if the model is actually a SelectItem) the flag will be dropped at mapping. The fix could be to copy the disabled flag in the ObjectUtils method (but I do not know what impact it might have on all other components using that method).
The text was updated successfully, but these errors were encountered: