Skip to content

How can I rewrite slotProps? There is no current implementation for customization slotProps due to internal feature #1178

Closed

Description

@xecei
function DatePickerWrapper(props: DatePickerWrapperProps) {
	const {
		input: { name, onChange, value, ...restInput },
		meta,
		showError = showErrorOnChange,
		...rest
	} = props;


	const { error, submitError } = meta;
	const isError = showError({ meta });

	const { helperText, textFieldProps, required, ...lessRest } = rest;

	return (
		<MuiDatePicker
			onChange={onChange}
			value={(value as any) === '' ? null : value}
			{...lessRest}
			slotProps={{
				textField: {
					...textFieldProps,
					helperText: isError ? error || submitError : helperText,
					inputProps: {
						onBlur: (event) => {
							restInput.onBlur(event);
						},
						onFocus: (event) => {
							restInput.onFocus(event);
						},
					},
					error: isError,
					fullWidth: true,
					name,
					onChange,
					value: (value as any) === '' ? null : value,
					required,
				},
			}}
		/>
	);
}

Wish i have field like "customSlotProps" that passes after textField so we could customize this native behaviour

for example

  customSlotProps={{
    field: { clearable: true},
  }}

Activity

  1. lookfirst commented on Nov 16, 2024

    @lookfirst
    Owner

    True, if we put {{...lessRest}} after slotProps, then you could override it. PR?

  2. Repository owner locked and limited conversation to collaborators on Apr 1, 2025
  3. converted this issue into a discussion #1184 on Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions