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

checkboxElement in MultiSelectPanelHeaderTemplateEvent has wrong interface #7622

Closed
alefduarte opened this issue Jan 18, 2025 · 0 comments · Fixed by #7623
Closed

checkboxElement in MultiSelectPanelHeaderTemplateEvent has wrong interface #7622

alefduarte opened this issue Jan 18, 2025 · 0 comments · Fixed by #7623
Assignees
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@alefduarte
Copy link
Contributor

Describe the bug

When customizing the panelHeaderTemplate of the MultiSelect, I encountered an issue where the checkboxElement is of type HTMLElement, which prevents me from using it directly.

I tried the following code:

const panelHeaderTemplate = (event: MultiSelectPanelHeaderTemplateEvent) => (
    <div className="p-multiselect-header" data-pc-section="header">
      {event.checkboxElement}
      {event.filterElement}
      {event.closeElement}
    </div>
);

This resulted in the error: Type 'HTMLElement' is not assignable to type 'string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined'.

Upon reviewing the interface, I noticed that both filterElement and closeElement are of type JSX.Element, while checkboxElement is the only one designated as HTMLElement. I believe this may be a mistake, as the following workaround compiles successfully:

const panelHeaderTemplate = (event: MultiSelectPanelHeaderTemplateEvent) => (
    <div className="p-multiselect-header" data-pc-section="header">
      {event.checkboxElement as unknown as JSX.Element}
      {event.filterElement}
      {event.closeElement}
    </div>
);

Thus, I suggest that the type of checkboxElement should be changed to JSX.Element.

I will open a PR with the proposed fix.

Reproducer

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

System Information

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
    Memory: 621.42 MB / 31.67 GB
  Binaries:
    Node: 22.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.4 - ~\AppData\Roaming\npm\npm.CMD
    pnpm: 9.15.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.19041.4355

Steps to reproduce the behavior

No response

Expected behavior

No response

@alefduarte alefduarte added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 18, 2025
@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 Jan 18, 2025
@melloware melloware added this to the 10.9.2 milestone Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
2 participants