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

TreeSelect: Incorrect TypeScript types for filterTemplate options #5102

Closed
1p0d opened this issue Oct 16, 2023 · 1 comment · Fixed by #5105
Closed

TreeSelect: Incorrect TypeScript types for filterTemplate options #5102

1p0d opened this issue Oct 16, 2023 · 1 comment · Fixed by #5105
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component. Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@1p0d
Copy link

1p0d commented Oct 16, 2023

Describe the bug

Almost exactly same issue as in #3506 just for TreeSelect.

Function parameter type provided for filterTemplate is incorrect.

filterTemplate?: React.ReactNode | ((options: TreeSelectFilterOptions) => React.ReactNode);

options object has properties {className, element, filterIconClassName, filterInputChange, filterInputKeyDown, filterOptions, props}, but it is marked as TreeSelectFilterOptions that is defined as following:

interface TreeSelectFilterOptions {
    filter?: (event?: KeyboardEvent) => void;
    reset?: () => void;
}

TreeSelectFilterOptions is matching filterOptions property on options.

Reproducer

https://codesandbox.io/p/sandbox/rough-darkness-v5k86h

PrimeReact version

10.0.3 (also encountered it in 9.6.1)

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 117

Steps to reproduce the behavior

  1. Go into codesandbox
  2. Search for something in the TreeSelect filter
  3. Open console and see the printouts of options and options.filterOptions
  4. Discover that options is not of type TreeSelectFilterOptions, but options.filterOptions is

Expected behavior

options should be of expected type.

@1p0d 1p0d added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 16, 2023
@melloware melloware added Typescript Issue or pull request is *only* related to TypeScript definition and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 16, 2023
@melloware melloware self-assigned this Oct 16, 2023
@melloware
Copy link
Member

Thanks for reporting I will fix it.

melloware added a commit to melloware/primereact that referenced this issue Oct 17, 2023
@melloware melloware added this to the 10.0.4 milestone Oct 17, 2023
@mertsincan mertsincan added the Type: Bug Issue contains a defect related to a specific component. label Oct 19, 2023
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. Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants