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

dropdown: selected, disabled option not rendered #14716

Closed
capc0 opened this issue Feb 5, 2024 · 3 comments · Fixed by #14768
Closed

dropdown: selected, disabled option not rendered #14716

capc0 opened this issue Feb 5, 2024 · 3 comments · Fixed by #14768
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@capc0
Copy link
Contributor

capc0 commented Feb 5, 2024

Describe the bug

When a dropdown has a disabled option that is initially selected by code, it is not rendered as the current selection.
It is a common use case that a dropdown has a current selection, that the user should change but to any value different than the currently selected one. Therefore the current/initial selected option gets disabled, so that it cannot be re-selected.

This used to be the case in Prime v15 and v16

Environment

see below

Reproducer

https://stackblitz.com/edit/github-npixcr?file=src%2Fapp%2Fapp.component.ts

Angular version

17.1.2

PrimeNG version

17.5.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18

Browser(s)

No response

Steps to reproduce the behavior

  1. open the stackblitz (see above)
  2. look at the following initial data in app.component.ts
  options: SelectItem[] = [
    { label: 'one', value: 1 },
    { label: 'two', value: 2, disabled: true },
    { label: 'three', value: 3 },
  ];
  selection = 2;
  1. view the result --> option two is not rendered/selected

image

Expected behavior

The selected option should be rendered, since it is already the current selection via model binding, even if it is disabled.

@capc0 capc0 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, 2024
@mehmetcetin01140 mehmetcetin01140 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 Feb 8, 2024
@cetincakiroglu cetincakiroglu added this to the 17.7.0 milestone Feb 12, 2024
cetincakiroglu added a commit that referenced this issue Feb 14, 2024
…dInitialSelectedOptionFixFor_7_6_0

fixed #14716 and fixed #14757 - updated computed label logic to also handle disabled selected option
@capc0
Copy link
Contributor Author

capc0 commented Feb 14, 2024

Thanks for the quick fix. However there is a follow-up issue with 17.7 detailed in #14809

@rmaleryk
Copy link

rmaleryk commented Jul 8, 2024

@cetincakiroglu
Looks like the fix is not working for the custom selectedItem template.

@MartinaAnt
Copy link

Same here in v17.18.4 - selectedItem template not working with (programmatically selected) disabled option

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
5 participants