Primeng: Spaces are not accepted in p-dropdown filters

Created on 14 Aug 2017  路  4Comments  路  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[ X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)

http://plnkr.co/edit/K1yVZnIGBmmTAe70934c?p=preview

Current behavior
In v4.1.3 spaces are not allowed in the dropdown filter

Expected behavior
Spaces should be allowed in the dropdown filters as they were in v4.1.2

Minimal reproduction of the problem with instructions

  1. Open a dropdown with a filter
  2. Try typing a space in the filter (for example: "race car".

Expected: "race car" should be an allowable search term.
Actual: Spaces are not allowed.

Please tell us about your environment:
MacOSX on Chrome

  • Angular version: 2.0.X
    4.2.6

  • PrimeNG version: 2.0.X
    4.1.3

  • Browser:
    Chrome

defect

Most helpful comment

Here's my suggested fix. If no one grabs this I'll put in a proper pull request later tonight or tomorrow night.

On this file: https://github.com/primefaces/primeng/blob/master/src/app/components/dropdown/dropdown.ts

change this (line 465):

        //space
        case 32:
            this.show();
            event.preventDefault();
        break;

to this:

        //space
        case 32:
            if(!this.panelVisible){
                this.show();
                event.preventDefault();
            }
        break;

All 4 comments

Looks like that's happening because the space key opens up the dropdown menu.

My guess at the proper behavior would be to check to see if the dropdown is already open before blocking the space key.

Here's the code:
image

Here's my suggested fix. If no one grabs this I'll put in a proper pull request later tonight or tomorrow night.

On this file: https://github.com/primefaces/primeng/blob/master/src/app/components/dropdown/dropdown.ts

change this (line 465):

        //space
        case 32:
            this.show();
            event.preventDefault();
        break;

to this:

        //space
        case 32:
            if(!this.panelVisible){
                this.show();
                event.preventDefault();
            }
        break;

Looks promising.

Thanks, fix checked in.

Was this page helpful?
0 / 5 - 0 ratings