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

DataTable HeaderCell: menu-type text filter does not accept spaces if the column is sortable #7459

Closed
pondermine opened this issue Nov 30, 2024 · 1 comment · Fixed by #7530
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@pondermine
Copy link

pondermine commented Nov 30, 2024

Describe the bug

If a DataTable column is sortable and has a simple text filter applied in "menu" style, then Spaces will not be allowed to be entered into the text input. This is prevented by a preventDefault around this line of code:

if ((event.code == 'Enter' || event.code === 'NumpadEnter' || event.code == 'Space') && event.currentTarget === elementRef.current && DomHandler.getAttribute(event.currentTarget, 'data-p-sortable-column') === true) {

Confirmed there is a workaround:

        <DataTable
          value={rowData}
          filters={filters}
          //This is a workaround because sortable column prevents default for Space
          onKeyDownCapture={(e) => {
            if (e.code === 'Space') e.stopPropagation();
          }}
...

Reproducer

https://stackblitz.com/edit/gbe2jc?file=src%2FApp.tsx

System Information

latest primereact and react-18

Steps to reproduce the behavior

  1. Find a text column that is sortable and has a menu filter (Country column in the reproducer)
  2. Click the filter icon
  3. Enter "Test Test" into the input text field

Observe: "TestTest" without the space is displayed as the entered text. The space is lost.

Expected behavior

The entered text should be "Test Test" with a space.

@pondermine pondermine added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 30, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 30, 2024
@melloware melloware added this to the 10.8.6 milestone Dec 30, 2024
@melloware melloware self-assigned this Dec 30, 2024
@melloware
Copy link
Member

Fixed for 10.8.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants