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 and Multiselect: ERROR TypeError: value.trim is not a function #12525

Closed
aleadkeyhole opened this issue Jan 19, 2023 · 20 comments
Closed
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@aleadkeyhole
Copy link

Describe the bug

image

Upgraded this morning, upon clicking a dropdown or multiselect specifically this error occurs. Appears that the trim() function is being called upon something else then a string.

Environment

irrelevant

Reproducer

No response

Angular version

15.1.0

PrimeNG version

15.1.0

Build / Runtime

TypeScript

Language

TypeScript

Node version (for AoT issues node --version)

v18.12.0

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@aleadkeyhole aleadkeyhole 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 19, 2023
@NahiaLC
Copy link

NahiaLC commented Jan 19, 2023

Same problem here!

Angular v15.1.1
PrimeNG v15.1.0
Node v16.15.1

@adglow-izemfr
Copy link

same problem here!

Angular v15.1.1
primeng v15.1.0
Node v18.13.0

@hugograf
Copy link
Contributor

It is maybe Angular bug, see ngClass klass property

@pkozlowski-opensource
Copy link

It is maybe Angular bug, see angular/angular#48779

Actually, the issue is that the overlay implementation is supplying an empty object ({}) to a binding that accepts strings only. The offending line seems to be https://github.com/primefaces/primeng/blob/master/src/app/components/overlay/overlay.ts#L117

So this is rather a bug that should be fixed on the PrimeNG side.

@olegkap
Copy link

olegkap commented Jan 20, 2023

I am experiencing the same issue after upgrade to 15.1

@PetrJajtner
Copy link

I think there is a problem with line _styleClass: string | undefined; (https://github.com/primefaces/primeng/blob/master/src/app/components/overlay/overlay.ts#L233) and invoking styleClass property. It is evaluated using ObjectUtils.merge where both parameters are undefined and therefore result of this method is empty object.
One possible solution is inserting them into the array and joining by space directly in getter:

get styleClass(): string {
  return [this._styleClass ?? '', (this.modal ? this.overlayResponsiveOptions?.styleClass : this.overlayOptions?.styleClass) ?? ''].join(' ').trim();
}

@AlejandroMHOB
Copy link

Same problem here. After update to primeng 15.1 with latest Angular version.

@cancrexo
Copy link

Same here.
ng 15.05
node 18.12
primeNG 15.1.0

Simple clicking on the dropdown throws error on console

@Phillip9587
Copy link

@olegkap
Copy link

olegkap commented Jan 20, 2023

Looks like the issue with Angular, like someone mentioned, I rolled back Angular to 15.1.0 and kept primeNG at 5.1.0 and all worked, so I think we need to test it once Angular 15.1.2 comes out perhaps.

@PetrJajtner
Copy link

PetrJajtner commented Jan 20, 2023

Nope, @olegkap , Angular 15 only simplified the setter named klass. The problem is in PrimeNG (see my comment above) which produced object instead of string. Btw. PrimeNG uses very ugly code with many types of any. I would recommend core team of PrimeNG to use strict type checking.

@olegkap
Copy link

olegkap commented Jan 20, 2023

I figured that what fixed it for me after I rolled back some changes so I thought it might be Angular 15.1.1.
I do agree some of the code in PrimeNG would be good to refactor when it comes to types.
I guess will wait then for PrimeNG 15.1.1

@yghandor
Copy link

it works with Version 15.1.0 and latest primeng (15.1.0)
and this is by just remove the "^"

@mertsincan mertsincan self-assigned this Jan 20, 2023
@mertsincan mertsincan 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 Jan 20, 2023
@mertsincan mertsincan added this to the 15.1.1 milestone Jan 20, 2023
@PetrJajtner
Copy link

PetrJajtner commented Jan 20, 2023

it works with Version 15.1.0 and latest primeng (15.1.0) and this is by just remove the "^"

I don't think so, @yghandor, try my project: https://stackblitz.com/edit/pj-angular-ngclass-setting-bug?file=package.json

@mertsincan
Copy link
Member

Thanks a lot for the report! Fixed now.

@klanglie
Copy link

I feel that this is not fixed. I am running latest angular, 15.2.8 and the latest PrimeNG, 15.4.1. Before updating, my project worked fine. It seems like it is PrimeNG and NOT Angular that is still the cause for this. I wish I could pinpoint further but have tried to debug and handle the error without any success so far.

@sbkt007
Copy link

sbkt007 commented Aug 21, 2023

My issue got resolved after updating the angular and primeng same version. I was installed angular 15.0.0 and primeng 15.0.0. Updated both the version to 15.2.1 it got resolved.

@abiram9291
Copy link

It is maybe Angular bug, see angular/angular#48779

Actually, the issue is that the overlay implementation is supplying an empty object ({}) to a binding that accepts strings only. The offending line seems to be https://github.com/primefaces/primeng/blob/master/src/app/components/overlay/overlay.ts#L117

So this is rather a bug that should be fixed on the PrimeNG sid

@abiram9291
Copy link

abiram9291 commented Oct 28, 2023

has this been fixed at all?
I am still facing this issue. any help is appreciated.

@bananalasmari
Copy link

bananalasmari commented Oct 31, 2023

same issue here any fixes?!

"@angular": "^15.0.0",
"primeng": "^15.0.0",

UPDATE: The issue fixed by updating both 15.2.0 version

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