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

P-multiselect component ignores disabled options if optionLabel property is used #9346

Closed
zandrei opened this issue Oct 1, 2020 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@zandrei
Copy link

zandrei commented Oct 1, 2020

I'm submitting a ... (check one with "x")

[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

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).

@cagataycivici cagataycivici added this to the 10.0.4 milestone Oct 11, 2020
@cagataycivici cagataycivici modified the milestones: 10.0.4, 10.1.0 Oct 19, 2020
@cagataycivici cagataycivici self-assigned this Nov 9, 2020
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Nov 9, 2020
@cagataycivici
Copy link
Member

Fixed via 4295

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