Skip to content

Commit

Permalink
Make default actions stable to avoid breaking possible memoization
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Jan 3, 2025
1 parent 88f2de9 commit 578640c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PickerOwnerState } from '@mui/x-date-pickers/models';
import resolveComponentProps from '@mui/utils/resolveComponentProps';
import { refType } from '@mui/utils';
import { PickerLayoutOwnerState } from '@mui/x-date-pickers/PickersLayout';
import { PickersActionBarAction } from '@mui/x-date-pickers/PickersActionBar';
import { rangeValueManager } from '../internals/utils/valueManagers';
import { DesktopDateRangePickerProps } from './DesktopDateRangePicker.types';
import { useDateRangePickerDefaultizedProps } from '../DateRangePicker/shared';
Expand All @@ -24,6 +25,8 @@ type DesktopDateRangePickerComponent = (<TEnableAccessibleFieldDOMStructure exte
React.RefAttributes<HTMLDivElement>,
) => React.JSX.Element) & { propTypes?: any };

const emptyActions: PickersActionBarAction[] = [];

/**
* Demos:
*
Expand Down Expand Up @@ -76,7 +79,7 @@ const DesktopDateRangePicker = React.forwardRef(function DesktopDateRangePicker<
...defaultizedProps.slotProps?.toolbar,
},
actionBar: (ownerState: PickerLayoutOwnerState) => ({
actions: [],
actions: emptyActions,
...resolveComponentProps(defaultizedProps.slotProps?.actionBar, ownerState),
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ import { renderDateViewCalendar } from '../dateViewRenderers';
import { resolveDateFormat } from '../internals/utils/date-utils';
import { buildGetOpenDialogAriaText } from '../locales/utils/getPickersLocalization';
import { PickerLayoutOwnerState } from '../PickersLayout';
import { PickersActionBarAction } from '../PickersActionBar';

type DesktopDatePickerComponent = (<TEnableAccessibleFieldDOMStructure extends boolean = true>(
props: DesktopDatePickerProps<TEnableAccessibleFieldDOMStructure> &
React.RefAttributes<HTMLDivElement>,
) => React.JSX.Element) & { propTypes?: any };

const emptyActions: PickersActionBarAction[] = [];

/**
* Demos:
*
Expand Down Expand Up @@ -78,7 +81,7 @@ const DesktopDatePicker = React.forwardRef(function DesktopDatePicker<
...defaultizedProps.slotProps?.toolbar,
},
actionBar: (ownerState: PickerLayoutOwnerState) => ({
actions: [],
actions: emptyActions,
...resolveComponentProps(defaultizedProps.slotProps?.actionBar, ownerState),
}),
},
Expand Down

0 comments on commit 578640c

Please sign in to comment.