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: placeholder isn't shown when having null as a selectable option #15308

Open
rubenteck opened this issue Apr 18, 2024 · 4 comments
Open
Assignees
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Pending Review Issue or pull request is being reviewed by Core Team
Milestone

Comments

@rubenteck
Copy link

Describe the bug

When adding null as a selectable option, the placeholder isn't shown on load, when selecting the null value (the 'empty' option) or when clearing the dropdown. In my example, the values are objects of type { label: 'label', value: 'value' } with the optionLabel and optionValue params set on the p-dropdown component. The null value is set as { label: null, value: null }.

Environment

I use a windows 11 laptop with IntelliJ. Angular 17.3.4, PrimeNG 17.13.0 and node v18.20.1.

Reproducer

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

Angular version

17.3.4

PrimeNG version

17.13.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v18.20.1

Browser(s)

No response

Steps to reproduce the behavior

  1. create a dropdown component with null value as an option (see stackblitz)
  2. start the app, the placeholder is not visible
  3. select the empty option, the placeholder is not visible
  4. click the clear button, the placeholder is not visible

Expected behavior

the dropdowns value should be the placeholder when loaded, cleared or empty is selected.

@rubenteck rubenteck added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 18, 2024
@cetincakiroglu cetincakiroglu added this to the 17.15.0 milestone Apr 19, 2024
@rosenthalj
Copy link
Contributor

rosenthalj commented Apr 22, 2024

PrimeNG's Dropdown allows the developer to define both a label and value. The problem you are experiencing is because you are not fully utilizing this capability. I have updated your original reproducer and with the changes the dropdown works as expected as long as you use the new getValue method to access the selected. PrimeNG, without any changes to the Dropdown component, can handle your use case.

updated reproducer: https://stackblitz.com/edit/github-bjxtkz-ueanuf?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts

The video below demonstrates your use case working properly with the current PrimeNG dropdown

dropdownWorkingCorrectly.mov

@rubenteck
Copy link
Author

Thank you for your solution. While it's possible to create an empty value like this, I don't think it solves the problem of the empty value not showing the placeholder when selected. If I'm wrong about this, please explain it further :)

@rosenthalj
Copy link
Contributor

Thank you for your solution. While it's possible to create an empty value like this, I don't think it solves the problem of the empty value not showing the placeholder when selected. If I'm wrong about this, please explain it further :)

I don't think I can explain further.

Obviously, it's up to PrimeNG to determine whether or not this issue #15308 is valid.

@cetincakiroglu cetincakiroglu modified the milestones: 17.15.0, 17.16.0 Apr 26, 2024
@cetincakiroglu cetincakiroglu added Status: Pending Review Issue or pull request is being reviewed by Core Team Status: Discussion Issue or pull request needs to be discussed by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 26, 2024
@cetincakiroglu cetincakiroglu modified the milestones: 17.16.0, 17.16.1, 17.16.2 May 3, 2024
@cetincakiroglu
Copy link
Contributor

Hi,

We're currently updating the tests. Once the dropdown is updated, we'll test this issue and your PR to avoid breaking changes. I'm moving this to the next milestone.

@cetincakiroglu cetincakiroglu modified the milestones: 17.16.2, 17.16.3 May 16, 2024
@cetincakiroglu cetincakiroglu self-assigned this May 16, 2024
@cetincakiroglu cetincakiroglu modified the milestones: 17.18.0, 18.Future May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
None yet
Development

No branches or pull requests

3 participants