Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default function MultiInputFieldSeparatorSlotProps() {
slotProps={{ separator: { sx: { opacity: 0.5 } } }}
/>
<DateRangePicker
slotProps={{ separator: { sx: { opacity: 0.5 } } }}
slotProps={{
field: { slotProps: { separator: { sx: { opacity: 0.5 } } } },
}}
slots={{ field: MultiInputDateRangeField }}
/>
</DemoContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default function MultiInputFieldSeparatorSlotProps() {
slotProps={{ separator: { sx: { opacity: 0.5 } } }}
/>
<DateRangePicker
slotProps={{ separator: { sx: { opacity: 0.5 } } } as any}
slotProps={{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverts the doc change done in #20293

field: { slotProps: { separator: { sx: { opacity: 0.5 } } } } as any,
}}
slots={{ field: MultiInputDateRangeField }}
/>
</DemoContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
slotProps={{ separator: { sx: { opacity: 0.5 } } }}
/>
<DateRangePicker
slotProps={{ separator: { sx: { opacity: 0.5 } } } as any}
slotProps={{
field: { slotProps: { separator: { sx: { opacity: 0.5 } } } } as any,
}}
slots={{ field: MultiInputDateRangeField }}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export const useDesktopRangePicker = <
<PickerRangePositionContext.Provider value={rangePositionResponse}>
<Field
{...fieldProps}
slots={slots}
slotProps={slotProps}
slots={{ ...slots, ...(fieldProps as any).slots }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not doing deep merge, people can't define slots or slotProps with both approach.
But I think that is more than fine, we are just trying to fix one specific scenario which is the multi-input specific slots, that the picker is not aware of 👍

Copy link
Member

@MBilalShafi MBilalShafi Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why useSlotProps doesn't return the correct type of fieldProps.

Copy link
Member Author

@flaviendelangle flaviendelangle Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it doesn't 😢
fieldProps.slots is not defined

slotProps={{ ...slotProps, ...(fieldProps as any).slotProps }}
{...(isSingleInput && {
inputRef,
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ export const useMobileRangePicker = <
<PickerRangePositionContext.Provider value={rangePositionResponse}>
<Field
{...fieldProps}
slots={slots}
slotProps={slotProps}
slots={{ ...slots, ...(fieldProps as any).slots }}
slotProps={{ ...slotProps, ...(fieldProps as any).slotProps }}
{...(isSingleInput && {
inputRef,
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ export const useDesktopPicker = <

const renderPicker = () => (
<PickerProvider {...providerProps}>
<Field {...fieldProps} slots={slots} slotProps={slotProps} inputRef={inputRef} />
<Field
{...fieldProps}
slots={{ ...slots, ...(fieldProps as any).slots }}
slotProps={{ ...slotProps, ...(fieldProps as any).slotProps }}
inputRef={inputRef}
/>
<PickerPopper slots={slots} slotProps={slotProps}>
<Layout {...slotProps?.layout} slots={slots} slotProps={slotProps}>
{renderCurrentView()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ export const useMobilePicker = <

const renderPicker = () => (
<PickerProvider {...providerProps}>
<Field {...fieldProps} slots={slots} slotProps={slotProps} inputRef={inputRef} />
<Field
{...fieldProps}
slots={{ ...slots, ...(fieldProps as any).slots }}
slotProps={{ ...slotProps, ...(fieldProps as any).slotProps }}
inputRef={inputRef}
/>
<PickersModalDialog slots={slots} slotProps={slotProps}>
<Layout {...slotProps?.layout} slots={slots} slotProps={slotProps}>
{renderCurrentView()}
Expand Down
Loading