Skip to content

Merging functional slotProps of a theme #48907

Description

@GerardasB

Steps to reproduce

Steps:

  1. Open this link to live example: https://stackblitz.com/edit/github-nxqwy3jw?file=src%2FApp.tsx
  2. Click the "Dashboard" button
  3. 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

Metadata

Metadata

Assignees

Labels

customization: themeHigher level theming customizability.not plannedThe problem seems valid, but we don't intend to fix it (won't fix).scope: menuChanges related to the menu.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions