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: Unable to type in editable Dropdowns when filtering options onChange and current value is an option #14556

Closed
c-o-l-i-n opened this issue Jan 15, 2024 · 1 comment · Fixed by #14628
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@c-o-l-i-n
Copy link
Contributor

Describe the bug

Given:
  • A Dropdown is editable,
  • The Dropdown has an array of options,
  • The Dropdown has an onChange callback that filters these options based on the current value,
When:
  • The user selects (or types) a value from the options,
  • And tries to type more text into the Dropdown,
Then:
  • The value of the Dropdown does not change.

For example:

The Dropdown options are ['apple', 'banana', 'orange']. The onChange handler filters the options based on the current dropdown value. The user types "apple" into the dropdown. They try to type " 2" to change the value to "apple 2", but the value remains "apple".

<p-dropdown
  #dropdown
  [options]="options"
  [editable]="true"
  (onChange)="onChange(dropdown, $event)"
/>
readonly options = ['apple', 'banana', 'orange'];

onChange(dropdown: Dropdown, event: DropdownChangeEvent): void {
  dropdown.options = this.options.filter((option) =>
    option
      .toLocaleLowerCase()
      .includes((event.value as string).toLocaleLowerCase())
  );
}

Environment

Stackblitz

Reproducer

https://stackblitz.com/edit/stackblitz-starters-vh2vfb?file=src%2Fmain.ts

Angular version

17.0.9

PrimeNG version

17.3.2

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

Whichever Node version Stackblitz uses

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a Dropdown with [editable]="true", an array of options, and an onChange handler that filters the options based on the Dropdown's current value.
  2. Select an item from the options.
  3. Try to add more text to the Dropdown.

Expected behavior

The user should be able to continue typing whatever they want into an editable Dropdown, even if the current value equals an option.

@c-o-l-i-n c-o-l-i-n 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 15, 2024
@mertsincan
Copy link
Member

Interesting! I set a milestone. We'll examine in detail what causes this issue.

@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 16, 2024
@mertsincan mertsincan added this to the 17.4.0 milestone Jan 16, 2024
@cetincakiroglu cetincakiroglu self-assigned this Jan 23, 2024
@cetincakiroglu cetincakiroglu modified the milestones: 17.4.0, 17.5.0 Jan 24, 2024
mehmetcetin01140 added a commit that referenced this issue Jan 25, 2024
…iltering options onChange and current value is an option
cetincakiroglu added a commit that referenced this issue Feb 1, 2024
Fixed #14556 - Dropdown | Unable to type in editable Dropdowns when f…
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