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

Chips: Add onKeyDown and KeyFilter #2797

Closed
AlesVykoukal opened this issue Apr 25, 2022 · 4 comments · Fixed by #2798
Closed

Chips: Add onKeyDown and KeyFilter #2797

AlesVykoukal opened this issue Apr 25, 2022 · 4 comments · Fixed by #2798
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@AlesVykoukal
Copy link

How to set insert to Chip component only certain characters.
For example, I want to enter from the list of characters "a, b, c, d, e, f, 1,2,3,4,5".

melloware added a commit to melloware/primereact that referenced this issue Apr 25, 2022
@melloware melloware changed the title Only specify characters for Chip component Chips: Only allow certain characters Apr 25, 2022
@melloware melloware self-assigned this Apr 25, 2022
@melloware melloware added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Apr 25, 2022
@melloware
Copy link
Member

I added onKeyDown event so you will be able to intercept key events before they go to Chip. For example to prevent the letter 'a' you could do...

    const onKeyDown = (event) => {
        if (event.which === 65) {
            event.preventDefault();
        }
    }

@AlesVykoukal
Copy link
Author

AlesVykoukal commented Apr 25, 2022

Is it possible to apply 'KeyFilter'?

@melloware
Copy link
Member

sure!

@melloware melloware changed the title Chips: Only allow certain characters Chips: Add onKeyDown and KeyFilter Apr 25, 2022
melloware added a commit to melloware/primereact that referenced this issue Apr 25, 2022
@melloware
Copy link
Member

KeyFilter added as well.

@melloware melloware added this to the 8.1.0 milestone Apr 26, 2022
melloware added a commit to melloware/primereact that referenced this issue Apr 29, 2022
melloware added a commit to melloware/primereact that referenced this issue May 11, 2022
melloware added a commit that referenced this issue Jul 1, 2022
* Fix #2797: Chips add onKeyDown callback

* Fix #2797: Chips add KeyFilter support

* Fix #2797: Chips add KeyFilter support

* Fix #2797: Chips add KeyFilter support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants