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

[Select][material-ui] Using notched property causes console warning in Chrome DevTools #38512

Open
2 tasks done
bpc1985 opened this issue Aug 17, 2023 · 9 comments
Open
2 tasks done
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material typescript

Comments

@bpc1985
Copy link

bpc1985 commented Aug 17, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to reproduce:
https://codesandbox.io/s/happy-beaver-xgjdhr?file=/App.tsx

Current behavior 😯

When trying to add notched property to Select component, it causes warning in devtools

 Warning: Received `true` for a non-boolean attribute `notched`.

If you want to write it to the DOM, pass a string instead: notched="true" or notched={value.toString()}.
    at div
    at https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:4564:46
    at InputBase2 (https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:27248:17)
    at Input4 (https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:38695:17)
    at https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:4564:46
    at Select4 (https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:45890:17)
    at div
    at https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:4564:46
    at FormControl4 (https://29yz35-5173.csb.app/node_modules/.vite/deps/@mui_material.js?v=313a1fab:35518:17)
    at DropdownList (https://29yz35-5173.csb.app/src/DropdownList.tsx:12:32)
    at div
    at App (https://29yz35-5173.csb.app/src/App.tsx?t=1692266366182:16:47)

Expected behavior 🤔

It should not show red warning

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@bpc1985 bpc1985 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 17, 2023
@zannager zannager added component: select This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Aug 17, 2023
@michaldudak michaldudak changed the title [Select][base-ui] Using notched property causes console warning in Chrome DevTools [Select][material-ui] Using notched property causes console warning in Chrome DevTools Aug 17, 2023
@michaldudak
Copy link
Member

The codesandbox you linked doesn't load and throws errors to the console (other than what you reported).
I created another one (not using Projects) but it seems to work fine: https://codesandbox.io/s/friendly-chatterjee-423hmm?file=/DropdownList.tsx
Could you take a look if I missed something?

@michaldudak michaldudak added status: waiting for author Issue with insufficient information package: material-ui Specific to @mui/material and removed package: base-ui Specific to @mui/base status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 17, 2023
@bpc1985
Copy link
Author

bpc1985 commented Aug 17, 2023

The codesandbox you linked doesn't load and throws errors to the console (other than what you reported). I created another one (not using Projects) but it seems to work fine: https://codesandbox.io/s/friendly-chatterjee-423hmm?file=/DropdownList.tsx Could you take a look if I missed something?

Hi,
I have already updated codesandbox: https://codesandbox.io/s/happy-beaver-xgjdhr?file=/App.tsx in github issue !

I also try to test your codesandbox and modifiy a little bit, it still show warning message in devtools

import { useState } from "react";
import { DropdownList } from "./DropdownList";

function App() {
  const [selectedValue, setSelectedValue] = useState(2);

  return (
    <DropdownList
      selectedValue={selectedValue}
      onChange={(e) => {
        setSelectedValue(Number(e.target.value));
      }}
      // listLabel="Test"
      size="small"
      options={[
        {
          label: "aaa",
          value: 1
        },
        {
          label: "bbb",
          value: 2
        }
      ]}
    />
  );
}

export default App;

You can see that warning in following picture

Screenshot 2023-08-17 152741

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Aug 17, 2023
@michaldudak
Copy link
Member

notched is a prop of the OutlinedInput. It does not exist on other variants.

@bpc1985
Copy link
Author

bpc1985 commented Aug 31, 2023

notched is a prop of the OutlinedInput. It does not exist on other variants.

I try to test like this

notched={ variant === 'outlined' }
even condition are true or false, it still generate warning

Warning: Received false for a non-boolean attribute notched.

Although type is
(property) notched?: boolean

@michaldudak
Copy link
Member

The type of the notched props isn't precise - it doesn't take the variant into consideration.

Try the following: notched={variant === 'outlined' ? true : undefined }

@bpc1985
Copy link
Author

bpc1985 commented Aug 31, 2023

Thanks, using your code notched={variant === 'outlined' ? true : undefined } works now !

@michaldudak
Copy link
Member

👍 anyway, I'll keep this issue open as it's an area for improvement.

@michaldudak michaldudak added bug 🐛 Something doesn't work typescript labels Aug 31, 2023
@michaldudak michaldudak removed their assignment Aug 31, 2023
@gicontz
Copy link

gicontz commented Nov 23, 2023

Better use spread of props.

{...{ notched: false }} />

@johnhunter
Copy link

I had the same warning when using InputBase to render the input prop of Select. Filtering it out of the props resolved the issue.

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: select 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

No branches or pull requests

5 participants