Skip to content

Autocomplete initial input value displayed to the user doesn't use the optionLabel provided. #19090

@jonatan-xapo

Description

@jonatan-xapo

Describe the bug

There is a problem using the autocomplete component and the properties optionLabel and optionValue. If the compoment has a preselected value, check the example for selectedCountry this one is displayed in the input without checking in the provided suggestions and usign the optionLabel provided.
In the demo provided you can see that for the pre selected value CA should display in the input Canada but instead if display CA

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

No response

Reproducer

https://stackblitz.com/edit/xudvtudh?file=src%2Fapp%2Fautocomplete-objects-demo.ts

Environment

Quite normal env, Mac, Chrome, I don't think this is relevant for this issue.

Angular version

20

PrimeNG version

v20

Node version

22.19.0

Browser(s)

Chrome but I think this isn't browser dependant

Steps to reproduce the behavior

There is no need for steps, this happens on first load of the autocomplete component, it doesn't use the optionLabel and display the value.

Expected behavior

When selectedCountry is initialized with a value it should display the suggestion label if avaialble respeting the optionLabel property. This means if selectedCountry is pre filled with CA and the optionLabel is provided and there is an entry in the suggestions that match this criteria the input should display Canada and not CA.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleIssue or pull request is inactivity and unfortunately it will be *closed* if there is no responseStatus: Needs TriageIssue will be reviewed by Core Team and a relevant label will be added as soon as possible

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions