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

Primeng KeyFilter does not working well when user do Cut, Copy and Paste #5752

Closed
lavchauhan opened this issue May 17, 2018 · 6 comments
Closed
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@lavchauhan
Copy link

lavchauhan commented May 17, 2018

Primeng KeyFilter does not working well when user do Cut, Copy and Paste.

Current behavior
After Applying pKeyFilter="pint" on input textbox still user can able to input alphbetics using this keys Cut or Copy and Paste / (CTRL + X or CTRL) + C and CTRL + V

Expected behavior
It should not be paste here when we have added pKeyFilter="pint" in input tags.

My environment:

  • Angular version:
    5.2.6

  • PrimeNG version:
    5.2.0

  • Browser:
    Chrome, Mozila Firefox, Safari, Internet Explorer 9,10,11

  • Language:
    TypeScript:2.4.2

  • Node (for AoT issues):
    6.11.0

@comlabmohan
Copy link

Any plan on the above issue in upcoming releases .

@ghost
Copy link

ghost commented Sep 13, 2018

Yes, I am also facing this issue. Kindly fix it in next release.

@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Dec 26, 2018
@cagataycivici cagataycivici added this to the 7.0.4 milestone Dec 26, 2018
cagataycivici added a commit that referenced this issue Dec 31, 2018
fixed #5752 Primeng KeyFilter does not working well when user do Cut,…
@steigerm
Copy link

Was this fix tested with IE?
I have implemented similar functionality before and had to use

        let input: string;
        if (typeof event.clipboardData === 'undefined') {
            //Internet Explorer
            input = (<any>window).clipboardData.getData('Text');
        } else {
            //all other browsers
            input = event.clipboardData.getData('Text');
        }

before testing the regex.

yigitfindikli added a commit that referenced this issue Dec 31, 2018
@cristianoquadros
Copy link

I have been some problem with pint mode. I really need to use paste in inputtext. So, my solution was change this part of the code:

@HostListener('paste', ['$event'])
onPaste(e) {
    const clipboardData = e.clipboardData || (<any>window).clipboardData;
    if (clipboardData) {
        const pastedText = clipboardData.getData('text');
        if (!this.regex.test(pastedText)) {
            e.preventDefault();
        }
    }
}

@shinde-prasad
Copy link

@cristianoquadros
Thanks for the solution but if you have to implement this in multiple forms then how would you do that like generic?

@ateffahi
Copy link

@cagataycivici
could you correct onPaste(e) for IE 11 please like that :
public onPaste(e) : void {
const clipboardData = e.clipboardData || (window as any).clipboardData;
if (clipboardData) {
const pastedText = clipboardData.getData('text');
for (let char of pastedText.toString()) {
if (!this.regex.test(char)) {
e.preventDefault();
return;
}
}
}
}
thanks to @cristianoquadros.

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

No branches or pull requests

8 participants