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

[docs] Wrongly documented default props in controlled/uncontrolled components #35822

Closed
2 tasks done
leonbloy opened this issue Jan 13, 2023 · 3 comments · Fixed by #35913
Closed
2 tasks done

[docs] Wrongly documented default props in controlled/uncontrolled components #35822

leonbloy opened this issue Jan 13, 2023 · 3 comments · Fixed by #35913
Assignees
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation

Comments

@leonbloy
Copy link

leonbloy commented Jan 13, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

This applies to several components , I'll take Accordion as an example but it also applies eg to Checkbox

https://mui.com/material-ui/api/accordion/

Accordion has boolean two related input props: expanded defaultExpanded

The API docs says that both defaults to false.

This is wrong and misleading.

expanded defaults to undefined . Which is different (and is treated very differently) from false.

Precisely, MUI assumes that the component is uncontrolled if (and only if) expanded (the "controlled value", as in useControlled hook) is undefined .

If the docs were right, then writing <Accordion defaultExpanded /> (or equivalently <Accordion defaultExpanded ={true} /> would be the same as writing <Accordion defaultExpanded expanded={false} />- which obviously is not the case

Current behavior 😯

No response

Expected behavior 🤔

No response

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@leonbloy leonbloy added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 13, 2023
@hbjORbj hbjORbj changed the title Wrongly documented default props in controlled/uncontrolled components [docs] Wrongly documented default props in controlled/uncontrolled components Jan 16, 2023
@hbjORbj hbjORbj added docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 16, 2023
@hbjORbj
Copy link
Member

hbjORbj commented Jan 23, 2023

This is indeed a bug. I will open a PR for a fix soon.

@hbjORbj hbjORbj added the bug 🐛 Something doesn't work label Jan 23, 2023
@hbjORbj
Copy link
Member

hbjORbj commented Jan 23, 2023

but it also applies eg to Checkbox

Can you tell me which props of Checkbox you are referring to?

@leonbloy
Copy link
Author

but it also applies eg to Checkbox

Can you tell me which props of Checkbox you are referring to?

checked and defaultChecked, they are equivalent to Accordion's expanded and defaultExpanded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants