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

[ListItemButton] Typescript error when passing Button or LoadingButton as component and using it with href and target #41452

Open
federico-ntr opened this issue Mar 11, 2024 · 1 comment
Assignees
Labels
bug 🐛 Something doesn't work component: list This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material typescript

Comments

@federico-ntr
Copy link

federico-ntr commented Mar 11, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/listitembutton-loadingbutton-repro-4mxwg5?file=%2Fsrc%2FDemo.tsx%3A9%2C41

Steps:
1.Open Demo.tsx and hover lines from 19 to 26 to see the error. The error is about the use of the target prop, which should be allowed when using href.

Current behavior

TypeScript complains about target not existing on type 'IntrinsicAttributes & { component: ExtendButton<LoadingButtonTypeMap<{}, "button">>; } & ListItemButtonOwnProps & Omit<...> & CommonProps & Omit<...>' if I pass LoadingButton to the component prop, along with href and target.

It still works fine, with a click opening the link in new tab if target="_blank", it's just TypeScript complaining.

Expected behavior

target should be supported as passing href results in the button using a as the root node

Context

I want to take advantage of the loading prop of LoadingButton, so it spins while the client is retrieving the href url.

Your environment

npx @mui/envinfo
  System:
    OS: macOS 14.2.1
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
    Edge: 122.0.2365.80
    Safari: 17.2.1
  npmPackages:
    @emotion/react: 11.11.4 => 11.11.4 
    @emotion/styled: 11.11.0 => 11.11.0 
    @mui/base:  5.0.0-beta.38 
    @mui/core-downloads-tracker:  5.15.12 
    @mui/icons-material: 5.15.12 => 5.15.12 
    @mui/lab: 5.0.0-alpha.167 => 5.0.0-alpha.167 
    @mui/material: 5.15.12 => 5.15.12 
    @mui/private-theming:  5.15.12 
    @mui/styled-engine:  5.15.11 
    @mui/system: 5.15.12 => 5.15.12 
    @mui/types:  7.2.13 
    @mui/utils:  5.15.12 
    @mui/x-data-grid: 6.19.6 => 6.19.6 
    @mui/x-date-pickers: 6.19.6 => 6.19.6 
    @types/react: 18.2.63 => 18.2.63 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    typescript: 5.4.2 => 5.4.2 

Search keywords: ListItemButton, LoadingButton, Button, target, component prop

@federico-ntr federico-ntr added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 11, 2024
@zannager zannager added the component: button This is the name of the generic UI component, not the React module! label Mar 11, 2024
@danilo-leal danilo-leal added component: list This is the name of the generic UI component, not the React module! typescript package: material-ui Specific to @mui/material and removed component: button This is the name of the generic UI component, not the React module! labels Mar 11, 2024
@KumarNitin19
Copy link
Contributor

@mj12albert & @federico-ntr I have added a fix for the above issue. @mj12albert Please review the PR.
Thanks!

@mj12albert mj12albert removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 14, 2024
@ZeeshanTamboli ZeeshanTamboli added the bug 🐛 Something doesn't work label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: list This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants