Steps to reproduce
Steps:
- Open this link to live example: https://stackblitz.com/edit/github-nxqwy3jw?file=src%2FApp.tsx
- Click the "Dashboard" button
- Observe that the
aria-labelledby attribute is not set on the list of a Menu component (element with role="menu".
Additionally, you can uncomment the lines that set the slotProps of the list as an object (in the theme) and observe that both the aria-labelledby of the theme and className of the component are merged.
Current behavior
The functional slotProps prop behaves differently than the object variant when set via the defaultProps of a theme.
When the object is used, the slotProps set on the component are merged with the slotProps of the theme. However, the function(al) slotProps of the theme is overridden entirely if the slotProps is set on the component.
This behavior is not ideal, as theme level customizations might be overridden unintentionally and pushes the theme customization towards the slots prop (when the ownerState is needed) - which is not ideal either, as it overrides MUI's default slots (usually just styling, but might include other functionality or internal components).
Expected behavior
(returned) Functional slotProps set via the defaultProps of a theme should be merged with slotProps set via the component.
Context
Working on a theme that customizes both the styling and semantics of MUI components - the ownerState is helpful to get the props passed in the component (or internal component state).
Your environment
No response
Search keywords: slotProps merging theme functional
Steps to reproduce
Steps:
aria-labelledbyattribute is not set on thelistof aMenucomponent (element withrole="menu".Additionally, you can uncomment the lines that set the
slotPropsof thelistas an object (in the theme) and observe that both thearia-labelledbyof the theme andclassNameof the component are merged.Current behavior
The functional
slotPropsprop behaves differently than the object variant when set via thedefaultPropsof a theme.When the object is used, the
slotPropsset on the component are merged with theslotPropsof the theme. However, the function(al)slotPropsof the theme is overridden entirely if theslotPropsis set on the component.This behavior is not ideal, as theme level customizations might be overridden unintentionally and pushes the theme customization towards the
slotsprop (when theownerStateis needed) - which is not ideal either, as it overrides MUI's default slots (usually just styling, but might include other functionality or internal components).Expected behavior
(returned) Functional
slotPropsset via thedefaultPropsof a theme should be merged withslotPropsset via the component.Context
Working on a theme that customizes both the styling and semantics of MUI components - the
ownerStateis helpful to get the props passed in the component (or internal component state).Your environment
No response
Search keywords: slotProps merging theme functional