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

Drodown: Unable to type spaces in editable dropdowns #14377

Closed
c-o-l-i-n opened this issue Dec 15, 2023 · 0 comments · Fixed by #14408
Closed

Drodown: Unable to type spaces in editable dropdowns #14377

c-o-l-i-n opened this issue Dec 15, 2023 · 0 comments · Fixed by #14408
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

Starting in PrimeNG 16.7.0, users cannot type spaces into an editable dropdown.

Pressing the space bar attempts to "complete" the dropdown rather than adding a space character.

It works in PrimeNG v16.6.0: https://stackblitz.com/edit/stackblitz-starters-nu65c1?file=src%2Fmain.ts
Broken in PrimeNG v16.7.0: https://stackblitz.com/edit/stackblitz-starters-rk61av?file=src%2Fmain.ts

The culprit seems to be this bit of code:

// dropdown.ts
onSpaceKey(event: KeyboardEvent, pressedInInputText: boolean = false) {
  !pressedInInputText && this.onEnterKey(event);
}

The onSpaceKey method executes the onEnterKey method if the space key is not pressed inside of the input. That makes sense. This would allow users to press the space key normally while inside the input. However, no value is ever passed into the pressedInInputText parameter, so it will always be false, thus never letting users type a space.

Current workaround: Disable the onSpaceKey method in any component that uses an editable Dropdown:

@ViewChild(Drodown) dropdown!: Dropdown;

ngAfterViewInit(): void {
  this.dropdown.onSpaceKey = (): void => {};
}

Environment

Stackblitz

Reproducer

https://stackblitz.com/edit/stackblitz-starters-rk61av?file=package.json,src%2Fmain.ts

Angular version

16.2.12

PrimeNG version

16.7.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

Whichever version Stackblitz uses

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a Dropdown with [editable]="true"
  2. Type a new value (one that does not match any options) that contains a space

Expected behavior

Users should be able to type spaces into editable dropdowns.

@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 Dec 15, 2023
@mehmetcetin01140 mehmetcetin01140 added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Dec 19, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 20, 2023
@cetincakiroglu cetincakiroglu added this to the 17.1.1 milestone Dec 20, 2023
cetincakiroglu added a commit that referenced this issue Dec 20, 2023
Fixed #14377 - Dropdown | Unable to type spaces in editable dropdowns
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.

3 participants