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: TypeError: this.getOptionLabel(...).toLocaleLowerCase is not a function #14865

Closed
shdb2 opened this issue Feb 23, 2024 · 2 comments · Fixed by #14959
Closed

Dropdown: TypeError: this.getOptionLabel(...).toLocaleLowerCase is not a function #14865

shdb2 opened this issue Feb 23, 2024 · 2 comments · Fixed by #14959
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@shdb2
Copy link

shdb2 commented Feb 23, 2024

Describe the bug

Declaring a dropdown with a filter or as editable with e.g. primitive number values (which are allowed according to the documentation), breaks the dropdown filter/edit option with the following error:

ERROR TypeError: this.getOptionLabel(...).toLocaleLowerCase is not a function
at _Dropdown.isOptionMatched (primeng-dropdown.mjs:2057:70)
at primeng-dropdown.mjs:2033:101
at Array.findIndex ()
at _Dropdown.searchOptions (primeng-dropdown.mjs:2033:76)
at _Dropdown.onEditableInput (primeng-dropdown.mjs:1632:26)
at Dropdown_input_3_Template_input_input_0_listener (primeng-dropdown.mjs:142:37)

Same problem as in issue #14370 and #14682: Has not been fixed yet despite the other issues being closed.

Environment

Chrome

Reproducer

No response

Angular version

17.2.x

PrimeNG version

17.7.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.11.0

Browser(s)

No response

Steps to reproduce the behavior

Stackblitz: https://stackblitz.com/~/github.com/shdb2/primeng-dropdown-test-v17

Expected behavior

Filtering and editing should be possible.

@shdb2 shdb2 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 23, 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 26, 2024
@dmitrymizernik
Copy link

I have the same problem with p-multiSelect after updating on 17.7.0.

@kongshu612
Copy link

kongshu612 commented Mar 5, 2024

this should be a bug from primeng side. or it is a break change.

  • you need to provide the filterFields property.
  • or if you option is like {label:string,value:xxx}[], you can bypass it by provide the optionLabel, optionValue.
  • or if your options are string[], it works as expected
    if you see code from 16.9.1.
const filteredOptions =
                !this.filterBy && !this.filterFields && !this.optionValue
                    ? this.options.filter((option) => option.toLowerCase().indexOf(this._filterValue().toLowerCase()) !== -1)
                    : this.filterService.filter(options, this.searchFields(), this._filterValue(), this.filterMatchMode, this.filterLocale);

Seems primeng Team has some ideas about the filterBy and filterFields. but that part is not completed.

@mehmetcetin01140 , Could you help to make it compatible for our existing code?

@mehmetcetin01140 mehmetcetin01140 self-assigned this Mar 7, 2024
@mehmetcetin01140 mehmetcetin01140 added this to the 17.10.0 milestone Mar 7, 2024
mehmetcetin01140 added a commit that referenced this issue Mar 7, 2024
cetincakiroglu added a commit that referenced this issue Mar 7, 2024
Fixed #14865 - Dropdown | TypeError: this.getOptionLabel(...).toLocal…
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

Successfully merging a pull request may close this issue.

4 participants