-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Description
This actually is a duplicate of #7981, but that issue is quite old and I think this would be worth re-visiting.
Summary 💡
Many Material UI components delegate to other Material UI components.
There are two main flavors of this delegation:
- Delegating to a root element wrapped by the main component. Any props not recognized by the main component will be passed down to this root element. Example:
MenuwrapsPopoverwhich in turn wrapsModal. - Delegating to components other than the root element. Props are generally passed to these components via a prop on the main component with a name of
<InnerComponentName>Props. Example:SelectleveragesMenuand receives props for theMenuelement via itsMenuPropsprop.
It is the first case (delegation to a root element) for which I think the documentation could be considerably improved.
Currently the documentation forces you to follow links to these other components in order to discover the full set of props that a component supports. Many people, especially new users of the library, do not notice (or fully understand) the "Any other props supplied will be provided to the root element" portion and miss the fact that many more props may be supported by the component. I think it would be much better for users of the documentation if all of the props from "inherited" components were included directly. So in the case of Menu, the props for Popover and Modal would be included directly in the Menu documentation. It seems like it should be doable for buildApi.js and generateMarkdown.js to be enhanced to automatically include the comprehensive props.
Examples 🌈
This Stack Overflow question shows one example of users assuming that a component (AppBar in this case) only supports the properties shown directly on its API page.
Motivation 🔦
I understand that the current way of documenting the properties was an easier approach to implement, but given the place of "Better documentation" within the roadmap priorities, I think it would be worth the additional complexity in the API doc generation (which is already aware of the inherited component) to allow users to find the comprehensive props more easily/quickly.