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

[Menu] MenuItem improperly inherits from Reacts Button type when it shouldn't especially when used in Select #34440

Open
2 tasks done
marcusjwhelan opened this issue Sep 22, 2022 · 1 comment
Labels
bug 🐛 Something doesn't work component: menu This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material typescript

Comments

@marcusjwhelan
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Steps:

  1. Attempt to use an object array in Select component with MenuItem value being a single object.

Current behavior 😯

This error on MenuItem when trying to assign an Object to the value

Overload 3 of 3, '(props: DefaultComponentProps<ExtendButtonBaseTypeMap<MenuItemTypeMap<{}, "li">>>): Element', gave the following error.
    Type 'AT' is not assignable to type 'string | number | string[]'.

Expected behavior 🤔

Not give me a typescript error about the value not conforming to React's button value typing when the component is not a value.

Context 🔦

I am attempting to use an array of objects for my select list. I am attempting to set the value to an object.

Setting the value to as any gets rid of the problem which to me means there is a bug with the way the component is typed.

In my example codeSandbox you will see a button being used with a proper error of an object being used for the value which it is true you cannot do this. facebook/react#25311

While on the MenuItem I can and it works so the types are wrong.

Here is a link to the codeSandbox. https://codesandbox.io/s/kind-pateu-pdfin6?file=/src/index.tsx

Add in as any on the value and the error goes away.

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@marcusjwhelan marcusjwhelan added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 22, 2022
@ZeeshanTamboli ZeeshanTamboli added the component: menu This is the name of the generic UI component, not the React module! label Sep 25, 2022
@hbjORbj hbjORbj changed the title MenuItem improperly inherits from Reacts Button type when it shouldn't especially when used in Select [Menu] MenuItem improperly inherits from Reacts Button type when it shouldn't especially when used in Select Oct 6, 2022
@hbjORbj hbjORbj added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 6, 2022
@michaldudak michaldudak added the package: material-ui Specific to @mui/material label May 12, 2023
@michaldudak
Copy link
Member

The Base UI's Select has this fixed. It contains a specific component to use within the Select: Option. It will be used to implement Material UI's Select in the future (likely starting work on it in Q3 2023).

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: menu 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.

5 participants