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

pSelectableRow blocks typing space on inputs in p-table #9893

Closed
themhassany opened this issue Feb 13, 2021 · 9 comments
Closed

pSelectableRow blocks typing space on inputs in p-table #9893

themhassany opened this issue Feb 13, 2021 · 9 comments
Assignees
Labels
LTS-FIXED-9.2.4 Fixed in PrimeNG LTS 9.2.4 LTS-FIXED-10.0.9 Fixed in PrimeNG LTS 10.0.9 Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@themhassany
Copy link

themhassany commented Feb 13, 2021

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

Current behavior
a row with pSelectableRow (<tr [pSelectableRow]="...">) blocks inputs from typing whitespace.

Expected behavior
We should be able to type whitespace in the inputs.

Minimal reproduction of the problem with instructions
https://codesandbox.io/s/lucid-shirley-53rlx?file=/src/app/app.component.html:233-247

The textarea will ignore the whitespace typed by the keyboard.

  • Angular version: 11.2.0
  • PrimeNG version: 11.2.1
  • Browser: [Chrome 88.0.4324.150 | Firefox 85.0.2 | not tested others]
@themhassany
Copy link
Author

I have reviewed the pSelectableRow directive. There is an event listener that cause this.

@HostListener('keydown.space', ['$event'])
onSpaceKeyDown(event: KeyboardEvent) {
    event.preventDefault();
}

can someone describe, why such a listener is needed?

@themhassany
Copy link
Author

a temporary fix can be the using (keydown.space)="$event.stopPropagation();" on text inputs. but this is not feasible for inputs in 3rd party components (e.g: filter input on p-dropdown)

@themhassany themhassany changed the title p-table with multiple <tr /> per each record with [pSelectableRow] doesn't allow whitespace in inputs (e.g.: textarea) pSelectableRow blocks typing space on inputs in p-table Feb 13, 2021
@yigitfindikli yigitfindikli self-assigned this Feb 15, 2021
@yigitfindikli yigitfindikli added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Feb 15, 2021
@yigitfindikli yigitfindikli modified the milestones: 11.2.2, 11.2.3 Feb 15, 2021
@yigitfindikli yigitfindikli added LTS-PORTABLE LTS-FIXED-10.0.8 Fixed in PrimeNG LTS 10.0.8 LTS-FIXED-10.0.9 Fixed in PrimeNG LTS 10.0.9 LTS-FIXED-9.2.4 Fixed in PrimeNG LTS 9.2.4 and removed LTS-FIXED-10.0.8 Fixed in PrimeNG LTS 10.0.8 LTS-PORTABLE labels Mar 1, 2021
@parth181195
Copy link

for some one looking for quick way to fix this and add space to inputs u can override this with this snippet

    @HostListener('keydown.space', ['$event'])
    onSpaceKeyDown(event: KeyboardEvent) {
        event.stopPropagation();
        event.preventDefault();
        if (event.target) {
            event.target['value'] = event.target['value'] + ' ';
            (event.target as HTMLElement).focus();
        }
    }

@philipp-doblhofer
Copy link

#14127 re-introduces this bug with commit d6a22d6

@NagornovAlex
Copy link

Ran into this issue. Had to implement workaround provided above. Please reopen the issue.

@Logic-Bits
Copy link

can confirm this is a big issue! setting [pSelectableRow]="rowData" and [pSelectableRowIndex]="rowIndex" also gives that faulty behavior

@NexPlex
Copy link

NexPlex commented Mar 25, 2024

I too, have the same issue I used parth181195 fix for now

"primeng": "^16.9.1",
"@angular/core": "16.2.12",
"@angular/forms": "16.2.12",

@Alextremeee
Copy link

This also seems to be an issue with a text area inside a Tree caused by this commit #14123. Looks like arrow keys, space, numpad enter and enter will all trigger a prevent default that will all break nested input/textarea elements.

@saidsoualhi
Copy link

saidsoualhi commented Oct 23, 2024

for some one looking for quick way to fix this and add space to inputs u can override this with this snippet

    @HostListener('keydown.space', ['$event'])
    onSpaceKeyDown(event: KeyboardEvent) {
        event.stopPropagation();
        event.preventDefault();
        if (event.target) {
            event.target['value'] = event.target['value'] + ' ';
            (event.target as HTMLElement).focus();
        }
    }

This doesn't work when you type a space between characters, it keeps adding space at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-FIXED-9.2.4 Fixed in PrimeNG LTS 9.2.4 LTS-FIXED-10.0.9 Fixed in PrimeNG LTS 10.0.9 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

9 participants