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

Component: Autocomplete #14615

Closed
rekna1 opened this issue Jan 23, 2024 · 4 comments
Closed

Component: Autocomplete #14615

rekna1 opened this issue Jan 23, 2024 · 4 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@rekna1
Copy link

rekna1 commented Jan 23, 2024

Describe the bug

Autocomplete bound to property that has value null displays [Object object]

Environment

"@angular/core": "^17.0.7",
"primeng": "^17.3.3",

Reproducer

No response

Angular version

17.0.7

PrimeNG version

17.3.3

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v20.10.0

Browser(s)

No response

Steps to reproduce the behavior

`
vm.viewData.besluitType= {
PrefLabel:null
}

<p-autoComplete appendTo="body" [ngModel]="vm.viewData.besluitType" class="flexauto"
[suggestions]="vm.besluitTypes" (completeMethod)="this.searchBesluitTypeSubj.next($event.query)"
(ngModelChange)="setBesluitTypeId($event)" field='PrefLabel' name="besluittype">


{{besluittype.PrefLabel}}


`

Expected behavior

I expect it to display an empty string as was the case in version 16

@rekna1 rekna1 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 23, 2024
@rekna1
Copy link
Author

rekna1 commented Feb 8, 2024

still having this issue with version 17.6

@rekna1
Copy link
Author

rekna1 commented Feb 11, 2024

I investigated the issue further, the autocomplete binds to { Id:null, Description:null }.
see comments in the code

 inputValue = computed(() => {
        const modelValue = this.modelValue();
        if (modelValue) {
            if (typeof modelValue === 'object') {
                const label = this.getOptionLabel(modelValue);
                // so label will be null and in this case it returns modelValue which is an object
                // the condition might be wrong, property Description exists on the model, it only contains null
                // so it should return null (or empty string)
                return label != null ? label : modelValue;
            }
            else {
                return modelValue;
            }
        }
        else {
            return '';
        }
    });

@shammill
Copy link

shammill commented Jul 4, 2024

Also having this issue. Having a null label will display as [Object object].
Introduced in v16. There is nothing in the change logs regarding this change in behaviour.

Related to
#14341

@mehmetcetin01140
Copy link
Contributor

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap?

Thanks a lot for your understanding!
Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

3 participants